Skip to content

Commit

Permalink
chore: resolve pr comments
Browse files Browse the repository at this point in the history
  • Loading branch information
kangmingtay committed Jun 10, 2024
1 parent b7d4a76 commit ac75297
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 35 deletions.
11 changes: 0 additions & 11 deletions internal/api/admin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -627,17 +627,6 @@ func (ts *AdminTestSuite) TestAdminUserSoftDeletion() {
// get soft-deleted user from db
deletedUser, err := models.FindUserByID(ts.API.db, u.ID)
require.NoError(ts.T(), err)

//lint:ignore SA1019 to be removed once the db columns are removed
require.Empty(ts.T(), deletedUser.ConfirmationToken)
//lint:ignore SA1019 to be removed once the db columns are removed
require.Empty(ts.T(), deletedUser.RecoveryToken)
//lint:ignore SA1019 to be removed once the db columns are removed
require.Empty(ts.T(), deletedUser.EmailChangeTokenCurrent)
//lint:ignore SA1019 to be removed once the db columns are removed
require.Empty(ts.T(), deletedUser.EmailChangeTokenNew)
//lint:ignore SA1019 to be removed once the db columns are removed
require.Empty(ts.T(), deletedUser.PhoneChangeToken)
require.Empty(ts.T(), deletedUser.EncryptedPassword)

// one time tokens table should be empty after a soft deletion
Expand Down
18 changes: 7 additions & 11 deletions internal/api/mail.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

"github.com/supabase/auth/internal/hooks"
mail "github.com/supabase/auth/internal/mailer"
"golang.org/x/sync/errgroup"

"github.com/badoux/checkmail"
"github.com/fatih/structs"
Expand Down Expand Up @@ -577,19 +578,14 @@ func (a *API) sendEmailChangeEmails(r *http.Request, tx *storage.Connection, u *
return a.invokeHook(tx, r, &input, &output, config.Hook.SendEmail.URI)
}

errors := make(chan error)
wg := new(errgroup.Group)
if config.Mailer.SecureEmailChangeEnabled && u.GetEmail() != "" {
go func(c chan error) {
c <- mailer.EmailChangeMail(r, u, ottCurrent, otp, referrerURL, externalURL)
}(errors)
go mailer.EmailChangeMail(r, u, ottCurrent, otp, referrerURL, externalURL)
}
go func(c chan error) {
c <- mailer.EmailChangeMail(r, u, ottNew, otpNew, referrerURL, externalURL)
}(errors)

// we return the first error that's sent to the channel
if e := <-errors; e != nil {
return e
go mailer.EmailChangeMail(r, u, ottNew, otpNew, referrerURL, externalURL)
if err := wg.Wait(); err != nil {
// we return the first not-nil error observed
return err
}
return nil
}
13 changes: 0 additions & 13 deletions internal/models/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,19 +63,6 @@ type User struct {
DONTUSEINSTANCEID uuid.UUID `json:"-" db:"instance_id"`

OneTimeTokens []OneTimeToken `json:"-" has_many:"one_time_tokens"`

// Deprecated: use the one_time_tokens model instead
ConfirmationToken string `json:"-" db:"confirmation_token"`
// Deprecated: use the one_time_tokens model instead
RecoveryToken string `json:"-" db:"recovery_token"`
// Deprecated: use the one_time_tokens model instead
EmailChangeTokenCurrent string `json:"-" db:"email_change_token_current"`
// Deprecated: use the one_time_tokens model instead
EmailChangeTokenNew string `json:"-" db:"email_change_token_new"`
// Deprecated: use the one_time_tokens model instead
PhoneChangeToken string `json:"-" db:"phone_change_token"`
// Deprecated: use the one_time_tokens model instead
ReauthenticationToken string `json:"-" db:"reauthentication_token"`
}

// NewUser initializes a new user from an email, password and user data.
Expand Down

0 comments on commit ac75297

Please sign in to comment.