I don't require my users to verify their email by entering the confirmation code. So I have set the pre-signup lambda trigger to return autoConfirmUser = true. This is confirming the user, but leaving their email in verified = false state.
Is there a way to verify all my users' email through code as an admin, without having to send the confirmation code?
I see in the documentation here
"You can also mark a user's email or phone number verified through this trigger." But I'm not sure how to do it, since the response for pre-signup lambda only accepts the autoConfirmUser attribute and not email_verified.
This is probably more of a question for the Cognito team themselves (rather than the SDK) so you might be better off opening a support case through the AWS console. FWIW I've read through the docs myself and it's not obvious how you can set this attribute - seems like the only thing you can do in the pre-signup trigger is set autoConfirmUser
Out of interest - why is it important to override the verified status? You say your application doesn't require it - without actually receiving an email and confirming via a code have users really verified?
You might also want to submit a question to the amazon-cognito team on stack-overflow : http://stackoverflow.com/questions/tagged/amazon-cognito
@kiiadi Thanks for your reply. Yes I did post my question in the AWS Cognito forum here. And I have found one working solution to auto verify the email. That is by using the adminUpdateUserAttributes API and passing email_verified = true as an attribute to it.
Another solution through the lambda trigger is suggested by AWS team member, that is to use autoVerifyEmail = true. But I havent tried this solution yet.
Out of interest - why is it important to override the verified status?
I require to override the email verified status, because I want to provide the forgot password option to user. And forgot password API does not work if user email is not verified.
hello @hithisisneel Are you find way to override the email verified status. I want to reset password without confirmation code, if you find way , please let me know , thanks.
@ijustyce Yes you can override email verification in the following ways:
Thanks @hithisisneel But in this way I only can confirm email address without confirm code when signup, still cannot find password without verify email address. If you known how to reset password without verification code , please tell me , thanks in advance.
@ijustyce I'm not sure I understand what you mean here. But, here are a couple of scenarios-
Go through the documentations here for more details
Go to Cognito > triggers > Pre sign-up
Add this lambda:
exports.handler = (event, context, callback) => {
event.response.autoConfirmUser = true;
context.done(null, event);
};
Hi Guys,
I am using email and phone number as username for my mobile APP. I am using cognito extension for dotnet and trying to finish challenges in while loop as per article: https://docs.aws.amazon.com/sdk-for-net/v3/developer-guide/cognito-authentication-extension.html
I only need to verify Phone number not email id however I need both as username.
I am running following lambda pre sign up trigger to autoverify email but it gives an error.
Pre Signup Lambda:
var response = require('cfn-response');
exports.handler = function(event, context, callback) {
if (event.triggerSource === 'PreSignUp_SignUp') {
if (event.request.userAttributes.hasOwnProperty('email')) {
event.response.autoVerifyEmail = true;
}
callback(null, event);
return
} callback(Misconfigured Cognito Trigger ${ event.triggerSource })
};
Error:
Phone or email cannot be auto verified, when user is not being auto confirmed.
If I confirm user in above lambda trigger using:
event.response.autoConfirmUser = true;
then email is verified. However since user is also confirmed, it doesn't sent SMS for phone verification.
could anyone please help/suggest?
Here's the Lambda function to achieve this: https://github.com/vbudilov/cognito-autoconfirm-user
Can't i do it in by Calling the userPool.signUp() function ?
@ijustyce Yes you can override email verification in the following ways:
- Use autoVerifyEmail = true in your pre-signup lambda trigger.
OR- Call the adminUpdateUserAttributes API and pass email_verified = true as an attribute to it.
Just for future reference, this is how I solved this using the AWS cli:
aws cognito-idp admin-update-user-attributes --user-pool-id <pool_id> --username <username> --user-attributes Name=email_verified,Value=true
Most helpful comment
Go to
Cognito > triggers > Pre sign-upAdd this lambda: