How to use the aws-amplify.Auth.currentUserInfo function in aws-amplify

To help you get started, we’ve selected a few aws-amplify examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github odyssy-automaton / pocket-moloch / src / contexts / Store.js View on Github external
const currentUser = async () => {
      try {
        // check if user is authenticated
        // try will throw if not
        const user = await Auth.currentAuthenticatedUser();
        // attributes are only updated here until re-auth
        // so grab attributes from here
        const attributes = await Auth.currentUserInfo();
        const realuser = { ...user, ...{ attributes: attributes.attributes } };

        setCurrentUser(realuser);

        // attach sdk
        // console.log("in load: realuser", realuser);
        const sdkEnv = getSdkEnvironment(
          SdkEnvironmentNames[`${config.SDK_ENV}`],
        );
        // check or set up local storage and initialize sdk connection
        const sdk = new createSdk(
          sdkEnv.setConfig('storageAdapter', localStorage),
        );
        await sdk.initialize();
        // check if account is connected in local storage
github aws-samples / connected-drink-dispenser-workshop / dispenser_app / src / views / auth / SignIn.vue View on Github external
.then(user => {
          this.isLoading = false;
          Auth.currentUserInfo()
            .then(info => {
              const payload = { username: user.username, jwt: user.signInUserSession.idToken.jwtToken };
              this.$store.dispatch("setLoggedIn", payload );
              this.statusMessage = "Loading user details";
              console.log("current user info ", info);
              console.log("initial JWT", user.signInUserSession.idToken.jwtToken)

              if (!this.redirectTo) {
                // No called route, send to root (/)
                this.$router.push({
                  path: "/",
                });
              } else {
                // When authenticated, forward to auth required route
                this.$router.push({
                  path: this.redirectTo
github pjay79 / MoviesApp / app / screens / AddMoviesScreen.js View on Github external
getUser = async () => {
    await Auth.currentUserInfo()
      .then((data) => {
        this.setState({ user: data.username });
      })
      .catch(error => console.log(`Error: ${error.message}`));
  };
github richardzcode / Journal-AWS-Amplify-Tutorial / step-06 / journal / src / modules / Home.jsx View on Github external
componentDidMount() {
        Auth.currentUserInfo()
            .then(user => this.setState({ user: user, path: user.id + '/' + today() + '/' }))
            .catch(err => console.log(err));
    }
github odyssy-automaton / pocket-moloch / src / auth / ChangePassword.js View on Github external
localStorage.getItem(`@archanova:${network}:device:private_key`),
            );

            const deviceValue = JSON.parse(
              localStorage.getItem(`@archanova:${network}:account_device`),
            );

            const store = await web3Service.getKeyStore(
              '0x' + keyValue.data,
              values.newPassword,
            );
            await Auth.updateUserAttributes(user, {
              'custom:encrypted_ks': JSON.stringify(store),
              'custom:device_address': deviceValue.device.address,
            });
            const attributes = await Auth.currentUserInfo();
            console.log('attributes', attributes);
            setCurrentUser( { ...currentUser, ...{ attributes: attributes.attributes } })
            setSubmitting(false);
            setAuthSuccess(true);
          } catch (err) {
            console.log('error changing pass: ', err);
            setSubmitting(false);
            setAuthError(err);
          }
        }}
      >
github pjay79 / MoviesApp / app / screens / AllMoviesScreen.js View on Github external
getUser = async () => {
    await Auth.currentUserInfo()
      .then((data) => {
        this.setState({ user: data.username });
        console.log(`Current user: ${this.state.user}`);
      })
      .catch(error => console.log(`Error: ${error.message}`));
  };
github odyssy-automaton / pocket-moloch / src / auth / UpgradeKeystore.js View on Github external
localStorage.getItem(`@archanova:${network}:device:private_key`),
            );

            const deviceValue = JSON.parse(
              localStorage.getItem(`@archanova:${network}:account_device`),
            );

            const store = await web3Service.getKeyStore(
              '0x' + keyValue.data,
              values.oldPassword,
            );
            await Auth.updateUserAttributes(user, {
              'custom:encrypted_ks': JSON.stringify(store),
              'custom:device_address': deviceValue.device.address,
            });
            const attributes = await Auth.currentUserInfo();
            console.log('attributes', attributes);
            setCurrentUser( { ...currentUser, ...{ attributes: attributes.attributes } })
            setSubmitting(false);
            setAuthSuccess(true);
          } catch (err) {
            console.log('error changing pass: ', err);
            setSubmitting(false);
            setAuthError(err);
          }
        }}
      >
github richardzcode / Journal-AWS-Amplify-Tutorial / step-04 / journal / src / modules / Home.jsx View on Github external
componentDidMount() {
        Auth.currentUserInfo()
            .then(user => this.setState({ user: user, path: user.id + '/' + today() + '/' }))
            .catch(err => console.log(err));
    }
github aws-samples / aws-appsync-relay / src / components / App.js View on Github external
constructor(props) {
    super(props);
    this.state = {userInfo: null};
    Auth.currentUserInfo().then(info => {
      this.setState({userInfo: info});
    })
  }
github Codebrahma / serverless-grocery-app / packages / CB-serverless-frontend / src / routes.js View on Github external
Auth.currentSession().then(async (response) => {
        const data = await Auth.currentAuthenticatedUser();
        const userData = await Auth.currentUserInfo();
        this.props.updateAuth({
          isAuthenticating: false,
          isAuthenticated: true,
          userData,
          identityId: data,
        });
        this.props.fetchAllOrders();
      }).catch((error) => {
        this.finishAuthentication();