Link Search Menu Expand Document

CognitoUser

Tasks

CLI

Related

{username: "kevin2", pool: CognitoUserPool, Session: null, client: Client, signInUserSession: CognitoUserSession, }
Session: null
attributes: {sub: "6a0583d9-2aff-48fa-a8a4-5941ae9471af", email_verified: true, email: "kevinslin8+2@gmail.com"}
authenticationFlowType: "USER_SRP_AUTH"
client: Client {endpoint: "https://cognito-idp.us-west-2.amazonaws.com/", fetchOptions: {}}
keyPrefix: "CognitoIdentityServiceProvider.4qh7bdns0d15fttfsumadevcmq"
pool: CognitoUserPool {userPoolId: "us-west-2_R0lrv1Vcb", clientId: "4qh7bdns0d15fttfsumadevcmq", client: Client, advancedSecurityDataCollectionFlag: true, storage: Storage}
preferredMFA: "NOMFA"
signInUserSession: CognitoUserSession {idToken: CognitoIdToken, refreshToken: CognitoRefreshToken, accessToken: CognitoAccessToken, clockDrift: 0}
storage: Storage {discourse_anon-topic-ids: "2051,3507,222", CognitoIdentityServiceProvider.4qh7bdns0d15fttfsumadevcmq.kevin2.clockDrift: "0", CognitoIdentityServiceProvider.19vkp969ss471e424pfh7trq33.kevintest.userData: "{"UserAttributes":[{"Name":"sub","Value":"349ff99a…alue":"kevin@thence.io"}],"Username":"kevintest"}", CognitoIdentityServiceProvider.19vkp969ss471e424pfh7trq33.LastAuthUser: "kevintest", safeLocalStorage: "true", }
userDataKey: "CognitoIdentityServiceProvider.4qh7bdns0d15fttfsumadevcmq.kevin2.userData"
username: "kevin2"
__proto__: Object

Cook

custom attributes

try {
  const currentUserInfo = await Auth.currentUserInfo()
  const favoriteFlavor = currentUserInfo.attributes['custom:favorite_flavor']
} catch (err) {
  console.log('error fetching user info: ', err);
}
  • update
const user = await Auth.currentAuthenticatedUser();
const result = await Auth.updateUserAttributes(user, {
    'custom:favorite_flavor': 'Strawberry'
})

Copyright © 2020 Thence LLC