forked from supabase/auth
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: remove legacy lookup in users for one_time_tokens (phase II) (s…
…upabase#1569) Removes legacy lookups in `auth.users` for when a corresponding entry in `one_time_tokens` is not found. Phase II of the refactor, based on supabase#1558, to be released after it's deployed for a few days. --------- Co-authored-by: Kang Ming <[email protected]>
- Loading branch information
Showing
9 changed files
with
261 additions
and
340 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -128,20 +128,24 @@ func (ts *ResendTestSuite) TestResendSuccess() { | |
u.EmailChangeSentAt = &now | ||
u.EmailChangeTokenNew = "123456" | ||
require.NoError(ts.T(), ts.API.db.Create(u), "Error saving new test user") | ||
require.NoError(ts.T(), models.CreateOneTimeToken(ts.API.db, u.ID, u.GetEmail(), u.ConfirmationToken, models.ConfirmationToken)) | ||
require.NoError(ts.T(), models.CreateOneTimeToken(ts.API.db, u.ID, u.EmailChange, u.EmailChangeTokenNew, models.EmailChangeTokenNew)) | ||
|
||
phoneUser, err := models.NewUser("1234567890", "", "password", ts.Config.JWT.Aud, nil) | ||
require.NoError(ts.T(), err, "Error creating test user model") | ||
phoneUser.EmailChange = "[email protected]" | ||
phoneUser.EmailChangeSentAt = &now | ||
phoneUser.EmailChangeTokenNew = "123456" | ||
require.NoError(ts.T(), ts.API.db.Create(phoneUser), "Error saving new test user") | ||
require.NoError(ts.T(), models.CreateOneTimeToken(ts.API.db, phoneUser.ID, phoneUser.EmailChange, phoneUser.EmailChangeTokenNew, models.EmailChangeTokenNew)) | ||
|
||
emailUser, err := models.NewUser("", "[email protected]", "password", ts.Config.JWT.Aud, nil) | ||
require.NoError(ts.T(), err, "Error creating test user model") | ||
phoneUser.PhoneChange = "1234567890" | ||
phoneUser.PhoneChangeSentAt = &now | ||
phoneUser.PhoneChangeToken = "123456" | ||
require.NoError(ts.T(), ts.API.db.Create(emailUser), "Error saving new test user") | ||
require.NoError(ts.T(), models.CreateOneTimeToken(ts.API.db, phoneUser.ID, phoneUser.PhoneChange, phoneUser.PhoneChangeToken, models.PhoneChangeToken)) | ||
|
||
cases := []struct { | ||
desc string | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,13 +4,14 @@ import ( | |
"bytes" | ||
"encoding/json" | ||
"fmt" | ||
mail "github.com/supabase/auth/internal/mailer" | ||
"net/http" | ||
"net/http/httptest" | ||
"net/url" | ||
"testing" | ||
"time" | ||
|
||
mail "github.com/supabase/auth/internal/mailer" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
"github.com/stretchr/testify/suite" | ||
|
@@ -127,6 +128,7 @@ func (ts *SignupTestSuite) TestVerifySignup() { | |
user.ConfirmationSentAt = &now | ||
require.NoError(ts.T(), err) | ||
require.NoError(ts.T(), ts.API.db.Create(user)) | ||
require.NoError(ts.T(), models.CreateOneTimeToken(ts.API.db, user.ID, user.GetEmail(), user.ConfirmationToken, models.ConfirmationToken)) | ||
|
||
// Find test user | ||
u, err := models.FindUserByEmailAndAudience(ts.API.db, "[email protected]", ts.Config.JWT.Aud) | ||
|
Oops, something went wrong.