Using the AWS's Cognito one can gain a lot since most of the functionalities (if not all) are already implemented by AWS. But I've faced a situation which I'm not sure how to implement using Cognito. Consider the following two scenarios:
Sign up:
Forgot password:
The statements above are tailored according to how AWS Cognito is implemented. And as you can see, the two final steps require different input in each of the scenarios. Now, my question is why AWS Cognito uses the same email template (in the second step) for both of them?
AFAIK, there's only one template in Cognito ("Message customizations" section) and it is used regardless of the email is sent to confirm user's email ownership or user has requested for a password reset code.
This is a problem for me since I want the content of the two emails to be different. For starters, they should contain different links in them.
Is there a way to send two different emails for confirmation code and forgot password in Cognito?
Reset password is the action of invalidating the current password for an account on a website, service, or device, and then creating a new one. A password may be reset using the settings of the software or service, or by contacting the customer service department.
Set up the reset password controller use App\Models\User; use Illuminate\Http\JsonResponse; use Illuminate\Support\Facades\Hash; use Illuminate\Support\Facades\Validator; Then, implement the resetPassword() method which allows the user to reset their password, by adding code below to the body of the class.
As it turned out the answer is to use Custom message from Triggers. Cognito lets you specify lambda functions for the different event generated in a user pool. One of which is Custom message. This lambda function is called each time an email is about to be sent to the client. Using the input data given to the lambda function, one can realize which scenario it is and compose the correct content for that email.
Here's the link to the documentation:
https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-custom-message.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With