This file contains hidden or 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
| function ChangePassword(username, password, newpassword) { | |
| var authenticationDetails = new AmazonCognitoIdentity.AuthenticationDetails({ | |
| Username: username, | |
| Password: password, | |
| }); | |
| var userData = { | |
| Username: username, | |
| Pool: userPool | |
| }; |
This file contains hidden or 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
| function deleteAttributes(username, password){ | |
| var attributeList = []; | |
| attributeList.push("custom:scope"); | |
| attributeList.push("name"); | |
| var authenticationDetails = new AmazonCognitoIdentity.AuthenticationDetails({ | |
| Username: username, | |
| Password: password, | |
| }); |
This file contains hidden or 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
| function DeleteUser() { | |
| var authenticationDetails = new AmazonCognitoIdentity.AuthenticationDetails({ | |
| Username: username, | |
| Password: password, | |
| }); | |
| var userData = { | |
| Username: username, | |
| Pool: userPool | |
| }; |
This file contains hidden or 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
| function renew() { | |
| const RefreshToken = new AmazonCognitoIdentity.CognitoRefreshToken({RefreshToken: "your_refresh_token_from_a_previous_login"}); | |
| const userPool = new AmazonCognitoIdentity.CognitoUserPool(poolData); | |
| const userData = { | |
| Username: "sample@gmail.com", | |
| Pool: userPool | |
| }; |
This file contains hidden or 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
| function ValidateToken(token) { | |
| request({ | |
| url: `https://cognito-idp.${pool_region}.amazonaws.com/${poolData.UserPoolId}/.well-known/jwks.json`, | |
| json: true | |
| }, function (error, response, body) { | |
| if (!error && response.statusCode === 200) { | |
| pems = {}; | |
| var keys = body['keys']; | |
| for(var i = 0; i < keys.length; i++) { | |
| //Convert each key to PEM |
This file contains hidden or 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
| function update(username, password){ | |
| var attributeList = []; | |
| attributeList.push(new AmazonCognitoIdentity.CognitoUserAttribute({ | |
| Name: "custom:scope", | |
| Value: "some new value" | |
| })); | |
| attributeList.push(new AmazonCognitoIdentity.CognitoUserAttribute({ | |
| Name: "name", | |
| Value: "some new value" | |
| })); |
This file contains hidden or 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
| function Login() { | |
| var authenticationDetails = new AmazonCognitoIdentity.AuthenticationDetails({ | |
| Username : 'sampleEmail@gmail.com', | |
| Password : 'SamplePassword123', | |
| }); | |
| var userData = { | |
| Username : 'sampleEmail@gmail.com', | |
| Pool : userPool | |
| }; |
This file contains hidden or 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
| function RegisterUser(){ | |
| var attributeList = []; | |
| attributeList.push(new AmazonCognitoIdentity.CognitoUserAttribute({Name:"name",Value:"Prasad Jayashanka"})); | |
| attributeList.push(new AmazonCognitoIdentity.CognitoUserAttribute({Name:"preferred_username",Value:"jay"})); | |
| attributeList.push(new AmazonCognitoIdentity.CognitoUserAttribute({Name:"gender",Value:"male"})); | |
| attributeList.push(new AmazonCognitoIdentity.CognitoUserAttribute({Name:"birthdate",Value:"1991-06-21"})); | |
| attributeList.push(new AmazonCognitoIdentity.CognitoUserAttribute({Name:"address",Value:"CMB"})); | |
| attributeList.push(new AmazonCognitoIdentity.CognitoUserAttribute({Name:"email",Value:"sampleEmail@gmail.com"})); | |
| attributeList.push(new AmazonCognitoIdentity.CognitoUserAttribute({Name:"phone_number",Value:"+5412614324321"})); | |
| attributeList.push(new AmazonCognitoIdentity.CognitoUserAttribute({Name:"custom:scope",Value:"admin"})); |