Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions internal/api/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
"net/http"
"time"

"github.com/fatih/structs"
"github.com/gofrs/uuid"
"github.com/supabase/auth/internal/api/apierrors"
"github.com/supabase/auth/internal/api/provider"
"github.com/supabase/auth/internal/api/sms_provider"
"github.com/supabase/auth/internal/mailer"
"github.com/supabase/auth/internal/models"
Expand Down Expand Up @@ -190,6 +192,38 @@
sessionID = &session.ID
}

emailIdentity, terr := models.FindIdentityByIdAndProvider(tx, user.ID.String(), "email")
if terr != nil && !models.IsNotFoundError(terr) {
return apierrors.NewInternalServerError("Error looking up email identity for user during password change").WithInternalError(terr)
}

phoneIdentity, terr := models.FindIdentityByIdAndProvider(tx, user.ID.String(), "phone")
if terr != nil && !models.IsNotFoundError(terr) {
return apierrors.NewInternalServerError("Error looking up phone identity for user during password change").WithInternalError(terr)
}

if emailIdentity == nil && user.GetEmail() != "" {
emailIdentity, terr = a.createNewIdentity(tx, user, "email", structs.Map(provider.Claims{

Check failure on line 206 in internal/api/user.go

View workflow job for this annotation

GitHub Actions / test

this value of emailIdentity is never used (SA4006)
Subject: user.ID.String(),
Email: user.GetEmail(),
EmailVerified: user.IsConfirmed() || config.Mailer.Autoconfirm,
}))
if terr != nil {
return apierrors.NewInternalServerError("Error creating missing email identity during password change").WithInternalError(terr)
}
}

if phoneIdentity == nil && user.GetPhone() != "" {
phoneIdentity, terr = a.createNewIdentity(tx, user, "phone", structs.Map(provider.Claims{

Check failure on line 217 in internal/api/user.go

View workflow job for this annotation

GitHub Actions / test

this value of phoneIdentity is never used (SA4006)
Subject: user.ID.String(),
Phone: user.GetPhone(),
PhoneVerified: user.IsPhoneConfirmed() || config.Sms.Autoconfirm,
}))
if terr != nil {
return apierrors.NewInternalServerError("Error creating missing phone identity during password change").WithInternalError(terr)
}
}

if terr = user.UpdatePassword(tx, sessionID); terr != nil {
return apierrors.NewInternalServerError("Error during password storage").WithInternalError(terr)
}
Expand Down
Loading