This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
Recover Password in AWS cognito is a 2 step process through email. In first step AWS sends a verification code | |
this verification has to be passed to step 2 with new password | |
*/ | |
recoverPasswordStep1(email) { | |
if (email.valid) { | |
const userData = { | |
Username: this.forgotparams.email, | |
Pool: userPool |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* This function will call the signIn() function from congnito AWS SDK. | |
* in login api. | |
*/ | |
signinUser() { | |
this.loading = true; | |
this.loginparams.username = this.loginparams.username.trim(); | |
this.loginparams.password = this.loginparams.password.trim() | |
try { | |
/** Create auth data */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
This function is used to add other attributes in user's cognito database | |
*/ | |
createRegistrationDataAttr(name, email, mobile) { | |
var attributeList = []; | |
var dataEmail = { | |
Name: 'email', | |
Value: email // your email here | |
}; | |
var dataPhoneNumber = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
*Pooldata const contain pooldata with user pool Id and client Id* | |
*/ | |
const PoolData = { | |
UserPoolId: Constants.USER_POOL.POOL_ID, | |
ClientId: Constants.USER_POOL.CLIENT_ID | |
}; | |
const userPool = new CognitoUserPool(PoolData); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
signup() { | |
this.loading = true; | |
/* User attributes consists of other attributes you need to store in cognito */ | |
let userAttributes = this.createRegistrationDataAttr(this.signinparams.name, this.signinparams.email, this.signinparams.contact_num); | |
try { | |
/* Sign up function */ | |
userPool.signUp(this.signinparams.email, this.signinparams.password, userAttributes, null, ((err, result) => { | |
if (err) { | |
this.loading = false; | |