Skip to content

Commit

Permalink
fix: update phone if autoconfirm is enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
kangmingtay committed Feb 15, 2024
1 parent 76a9fe4 commit ac44a8d
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 6 deletions.
1 change: 1 addition & 0 deletions internal/api/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ func (a *API) UserUpdate(w http.ResponseWriter, r *http.Request) error {

if params.Phone != "" && params.Phone != user.GetPhone() {
if config.Sms.Autoconfirm {
user.PhoneChange = params.Phone
if _, terr := a.smsVerify(r, ctx, tx, user, &VerifyParams{
Type: phoneChangeVerification,
Phone: params.Phone,
Expand Down
6 changes: 0 additions & 6 deletions internal/models/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,12 +305,6 @@ func (u *User) UpdatePassword(tx *storage.Connection, sessionID *uuid.UUID) erro
}
}

// UpdatePhone updates the user's phone
func (u *User) UpdatePhone(tx *storage.Connection, phone string) error {
u.Phone = storage.NullString(phone)
return tx.UpdateOnly(u, "phone")
}

// Authenticate a user from a password
func (u *User) Authenticate(ctx context.Context, password string) bool {
err := crypto.CompareHashAndPassword(ctx, u.EncryptedPassword, password)
Expand Down

0 comments on commit ac44a8d

Please sign in to comment.