amplify cognito delete user

Solutions on MaxInterview for amplify cognito delete user by the best coders in the world

showing results for - "amplify cognito delete user"
Hattie
21 Sep 2017
1const AWS = require('aws-sdk');
2const cognitoIdentity = new AWS.CognitoIdentityServiceProvider({ region: 'us-east-1' }); //replace with the region of your user pool
3
4const UserPoolId = process.env.UserPoolId;
5
6exports.handler = async (event) => {
7    const { idToken } = event;
8
9    //TODO: validate and decode idToken
10    //https://docs.aws.amazon.com/cognito/latest/developerguide/amazon-cognito-user-pools-using-tokens-verifying-a-jwt.html
11
12    const Username = decodedIdToken["cognito:username"];
13
14    const deleteParams = {
15        Username,
16        UserPoolId
17    }
18
19    try {
20        const result = await cognitoIdentity.adminDeleteUser(deleteParams).promise();
21        return result;
22    } catch (e) {
23        console.log(`error deleting user ${Username}: ${e}`)
24        throw e;
25    }
26}
27
similar questions
queries leading to this page
amplify cognito delete user