amazon web services - AWS Cognito - how to create user record in dynamodb after a user confirms registration -
i'm trying create user record in ddb cognito users once confirm registration. wish use (federated) identity id of user primary key.
however, identity id not available in postconfirmation lambda trigger. in fact, identity id not available until user authenticates access token. guess makes sense given cognito user pools provider, facebook , google. wouldn't create identity until login provider.
unlike facebook , google, there no oauth callback hit create record when signing cognito user pool. user signs in so:
cognitouser.authenticateuser(authenticationdetails, { onsuccess: function (result) { console.log('access token + ' + result.getaccesstoken().getjwttoken()); aws.config.credentials = new aws.cognitoidentitycredentials({ identitypoolid: self.identitypoolid, logins: { [`cognito-idp.${self.region}.amazonaws.com/${self.pooldata.userpoolid}`]: result.getidtoken().getjwttoken() } }); console.log("authservice: set aws credentials - " + json.stringify(aws.config.credentials)); self.currentuser = cognitouser; cb(null, result); }, onfailure: function(err) { console.log(err); cb(err, null); } }); only identity id created. standard way implement creating user record? standard create record when user first signs in?
there's few ways this, think. 1 might use sub value key instead of identity id. it's given user on creation, , globally unique (like identity id). if go route, thought using postconfirmation callback great.
if want identity id (which might if have other aws resources access , want access them), might recommend building own hook onsuccess block there. check if row identity id exists, , nothing if so. if not, create it. make sense use case? or there more wrinkles?
Comments
Post a Comment