aws-amplify / amplify-js

A declarative JavaScript library for application development using cloud services.
https://docs.amplify.aws/lib/q/platform/js
Apache License 2.0
9.42k stars 2.12k forks source link

Redirect to url after clicking email verification link  #9006

Open saad8it opened 2 years ago

saad8it commented 2 years ago

Is this related to another service?

Cognito

Describe the feature you'd like to request

Opening the issue again previously posted by another user

When the user clicks on the email verification link, they're taken to a confirmation page, located at https://APP.auth.us-east-2.amazoncognito.com/confirmUser?client_id=CLIENT_ID&user_name=USERNAME&confirmation_code=CODE

I'd like the ability to specify a URL that the confirmation page will redirect to, thereby auto logging in the user. This will make the signup flow more streamlined. Perhaps there could be an extra parameter for the redirect url. https://APP.auth.us-east-2.amazoncognito.com/confirmUser?client_id=CLIENT_ID&user_name=USERNAME&confirmation_code=CODE&redirect=URL

The way it works now is that after clicking the link, the user has to go back to my app and log in again, which is awkward.

Describe the solution you'd like

The way it works now is that after clicking the link, the user has to go back to my app and log in again, which is awkward.

Describe alternatives you've considered

I have tried using lambda triggers but having difficulties setting it up

alexandervonwl commented 1 year ago

Hi, is this implemented, I want to redirect, not using amplify, just cognito? Thank you :)

ledgerdevelop commented 1 year ago

This is really basic auth feature needed as the UX ist really bad otherwise. The workaround is terrible right now and autoSignIn is still a struggle. Come on: if you want to make amplify better and usable work on this ASAP please. It is in high demand by the amplify dev community.

oantacamelia commented 1 year ago

We are building a flutter app and wanted to redirect the user to the app after he clicks the confirmation link received in the email. Please consider adding this feature, indeed the UX is really bad. Still waiting for a solution, if anyone had any luck to find a workaround for this.

ghost commented 1 year ago

+1, otherwise UI looks really bad

gmicek commented 1 year ago

+1 we want this thanks!

BernhardSmuts commented 11 months ago

Any movement on this feature?

clairolzam commented 9 months ago

+1

mahmoud-anwer commented 4 months ago

Any updates?

saad8it commented 4 months ago

Sorry for the late Update i did find a solution back when i was implementing (2021) and i documented the process so sharing the logic hopefully it works till now too

For verify Aws user verification customization follow the following steps

1-Create a lambda function from the following link

https://eu-central-1.console.aws.amazon.com/lambda/home?region=eu-central-1#/functions

2-After creating lambda function paste the following code into the lamda function

` exports.handler = (event, context, callback) => {

if(event.triggerSource === "CustomMessage_SignUp") {

    console.log('function triggered');

    console.log(event);

    // Ensure that your message contains event.request.codeParameter. This is the placeholder for code that will be sent
    const { codeParameter } = event.request

    const { userName, region } = event

    const { clientId } = event.callerContext

    const { email } = event.request.userAttributes

    const url = 'use the url of your app'

    const link = `<a href="${url}?code=${codeParameter}&username=${userName}&clientId=${clientId}&region=${region}&email=${email}" target="_blank">Verify
    </a>
    `

    event.response.emailSubject = "Your verification link"; // event.request.codeParameter

    event.response.emailMessage = `<!DOCTYPE html>
` 3- Go to User Pool 4-Click on the trigger option image 5-Select the already created lambda function in post confirmation image 6-Save changes 7-click on the message customization in user pool cognito 7- Now here we have to change link to code image
asyschikov commented 3 months ago

How is the internal conversation going?

jmelo11 commented 3 days ago

Is this working?

saad8it commented 3 days ago

Yes it is working