Skip to content

Conversation

kangmingtay
Copy link
Member

What kind of change does this PR introduce?

  • Shortens email otp sent when the user requests for a confirmation, recovery, invite, email change, reauthentication and magic links
  • Email otps will now be sent with a fixed length of 10 and will only contain alphanumeric characters
  • Adds a partial unique index on the following db fields: confirmation_token, recovery_token, email_change_token_new, email_change_token_current, reauthentication_token

@kangmingtay kangmingtay self-assigned this Apr 14, 2022
Copy link
Contributor

@J0 J0 left a comment

Choose a reason for hiding this comment

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

Looks good to me

Copy link
Member

@awalias awalias left a comment

Choose a reason for hiding this comment

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

looks good just a couple of questions

crypto/crypto.go Outdated

// GenerateEmailOtp generates a random n-length alphanumeric otp
func GenerateEmailOtp(length int) (string, error) {
const charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
Copy link
Member

@awalias awalias Apr 15, 2022

Choose a reason for hiding this comment

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

I think it's ok but are there any situations where upper case chars could get squashed? (I can't think of any)

@kangmingtay kangmingtay changed the title fix: shorten email otp [WIP] fix: shorten email otp Apr 15, 2022
@kangmingtay
Copy link
Member Author

block on this for the time being because we need to run the migration to create the new indices concurrently which isn't supported by the current migration tool (soda)

will be swapping that out for sql-migrate

@RatulSaha
Copy link

A typical user journey is to look at the OTP in phone while doing it in web/iPad. This is quite common to not context switch, as people are often comfortable checking email (like SMS) in phone.

On that note, can we have a consistent experience, where we do not assume that it will be copy pasted? Most providers do lowercase alphabets only, for example. Making them a multiple of 4 is also common for the same reason, it makes it possible to remember chunks and type it out.

@kangmingtay kangmingtay changed the title [WIP] fix: shorten email otp fix: shorten email otp Apr 22, 2022
@kangmingtay kangmingtay merged commit c64f331 into master Apr 23, 2022
@kangmingtay kangmingtay deleted the km/fix-shorten-otp branch April 23, 2022 00:00
@github-actions
Copy link
Contributor

🎉 This PR is included in version 2.6.22 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@kangmingtay kangmingtay mentioned this pull request May 9, 2022
2 tasks
uxodb pushed a commit to uxodb/auth that referenced this pull request Nov 13, 2024
* fix: add unique indices to user token columns

* fix: shorten email otp

* remove phone_change_token from migration

* fix: use enums for each token type

* refactor: use RawURLEncoding instead of removePadding

* fix: update token format & verify

* add description for v1 otp
LashaJini pushed a commit to LashaJini/auth that referenced this pull request Nov 13, 2024
* fix: add unique indices to user token columns

* fix: shorten email otp

* remove phone_change_token from migration

* fix: use enums for each token type

* refactor: use RawURLEncoding instead of removePadding

* fix: update token format & verify

* add description for v1 otp
LashaJini pushed a commit to LashaJini/auth that referenced this pull request Nov 15, 2024
* fix: add unique indices to user token columns

* fix: shorten email otp

* remove phone_change_token from migration

* fix: use enums for each token type

* refactor: use RawURLEncoding instead of removePadding

* fix: update token format & verify

* add description for v1 otp
cemalkilic pushed a commit that referenced this pull request Aug 7, 2025
* fix: add unique indices to user token columns

* fix: shorten email otp

* remove phone_change_token from migration

* fix: use enums for each token type

* refactor: use RawURLEncoding instead of removePadding

* fix: update token format & verify

* add description for v1 otp
xeladotbe pushed a commit to xeladotbe/supabase-auth that referenced this pull request Sep 27, 2025
* fix: add unique indices to user token columns

* fix: shorten email otp

* remove phone_change_token from migration

* fix: use enums for each token type

* refactor: use RawURLEncoding instead of removePadding

* fix: update token format & verify

* add description for v1 otp
issuedat pushed a commit that referenced this pull request Sep 30, 2025
* fix: add unique indices to user token columns

* fix: shorten email otp

* remove phone_change_token from migration

* fix: use enums for each token type

* refactor: use RawURLEncoding instead of removePadding

* fix: update token format & verify

* add description for v1 otp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants