8000 Feat email code by christyjacob4 · Pull Request #3912 · appwrite/appwrite · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Feat email code #3912

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 9 commits into from
Closed

Feat email code #3912

wants to merge 9 commits into from

Conversation

christyjacob4
Copy link
Member
@christyjacob4 christyjacob4 commented Sep 23, 2022

What does this PR do?

Until now we could only perform email verification using a redirect URL sent via email. A recent feature request asked for the same verification to be performed using an OTP style code. This PR allows us to perform email verification using a short lived code

Screen.Recording.2022-09-23.at.1.51.17.PM.mov

TODOs

  • Tests
  • Decide whether we need a new endpoint for this or reuse the existing one ?
  • Update language templates for other languages
  • Maybe introduce an env var to set the token expiration time

Test Plan

TBD

Related PRs and Issues

#3893

Have you read the Contributing Guidelines on issues?

YES

@christyjacob4
Copy link
Member Author

I realised if we reuse the existing endpoint, it will lead to a breaking change . However, with a new endpoint, we can ship this feature without a breaking change. Thoughts ?
@stnguyen90 @Meldiron @eldadfux @TorstenDittmann

@stnguyen90
Copy link
Contributor

I realised if we reuse the existing endpoint, it will lead to a breaking change . However, with a new endpoint, we can ship this feature without a breaking change.

@christyjacob4, what makes it breaking?

@christyjacob4
Copy link
Member Author

Screenshot 2022-10-25 at 7 27 14 PM
@stnguyen90 The new parameter added to the endpoint would be a breaking change for languages like Java, Kotlin, etc.

@@ -2090,6 +2091,7 @@
->label('abuse-limit', 10)
->label('abuse-key', 'url:{url},userId:{userId}')
->param('url', '', fn($clients) => new Host($clients), 'URL to redirect the user back to your app from the verification email. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API.', false, ['clients']) // TODO add built-in confirm page
->param('code', false, new Boolean(true), 'Whether the email verification email must contain a URL or a secret code.', true)
Copy link
Member
@abnegate abnegate Oct 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about using a type parameter here with a string whitelist instead? Then we would be free to add more types in future without an API change

case MAIL_TYPE_MAGIC_SESSION:
$subject = $locale->getText("$prefix.subject");
break;
default:
throw new Exception('Undefined Mail Type : ' . $type, 500);
}

var_dump($code);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's remove this

Comment on lines 12 to 17
"emails.verificationCode.subject": "Account Verification",
"emails.verificationCode.hello": "Hey {{name}}",
"emails.verificationCode.body": "Please use the following code to verify your email address. Note that this code is only valid for 15 minutes.",
"emails.verificationCode.footer": "If you didn’t ask to verify this address, you can ignore this message.",
"emails.verificationCode.thanks": "Thanks",
"emails.verificationCode.signature": "{{project}} team",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lots of these are duplicate, what do you think about keeping ones that are as "emails.verification.subject" and specifying per type as "emails.verification.code.body" for example? Then we could fetch them without having to check the type like "emails.verification.{$type}.body"

@abnegate
Copy link
Member

The new parameter added to the endpoint would be a breaking change for languages like Java, Kotlin, etc.

This would not be breaking as the parameter is optional and is added as the last parameter; it would be automatically set to null, then excluded from the request so the API default would be used

@eldadfux
Copy link
Member

Please address Jake's comments. I agree calling the param code might be problematic. Also, this makes translations and custom email templates much more complex.

Have we considered adding a new endpoint for verification with code with its own template for easier translation maintenance? Not sure how it should be structured, but would love to hear your thoughts.

@joeyouss joeyouss mentioned this pull request Jul 17, 2023
2 tasks
@binaryfire
Copy link

It'd be great to move this forward. @Cvr421 offered to assist with this in another thread. Perhaps he could help?

Some new info re: OTPs:

@FaisalMohammadi
Copy link

@binaryfire you are absolutely right. I am also waiting for this feature for very long time. Will be also happy to have this feature as soon as possible.

@ajitsinghkaler
Copy link

This will be very helpful

@stnguyen90 stnguyen90 mentioned this pull request Jan 11, 2024
2 tasks
@christyjacob4
Copy link
Member Author

Not relevant anymore since it was released in #7422

@christyjacob4 christyjacob4 deleted the feat-email-code branch May 23, 2024 19:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants
0