Skip to content

Commit

Permalink
fix: revert refactor resource owner password grant (supabase#1466)
Browse files Browse the repository at this point in the history
Reverts supabase#1443 - on second thought I don't think it is
such a good idea - benefits are also marginal
  • Loading branch information
J0 authored Mar 4, 2024
1 parent e63ad6f commit fa21244
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions internal/api/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,29 +117,27 @@ func (a *API) ResourceOwnerPasswordGrant(ctx context.Context, w http.ResponseWri

grantParams.FillGrantParams(r)

switch {
case params.Email != "" && config.External.Email.Enabled:
if params.Email != "" {
provider = "email"
if !config.External.Email.Enabled {
return badRequestError("Email logins are disabled")
}
user, err = models.FindUserByEmailAndAudience(db, params.Email, aud)

case params.Phone != "" && config.External.Phone.Enabled:
} else if params.Phone != "" {
provider = "phone"
if !config.External.Phone.Enabled {
return badRequestError("Phone logins are disabled")
}
params.Phone = formatPhoneNumber(params.Phone)
user, err = models.FindUserByPhoneAndAudience(db, params.Phone, aud)

case !config.External.Email.Enabled:
return badRequestError("Email logins are disabled")

case !config.External.Phone.Enabled:
return badRequestError("Phone logins are disabled")

default:
} else {
return oauthError("invalid_grant", InvalidLoginMessage)
}

if err != nil && models.IsNotFoundError(err) {
return oauthError("invalid_grant", InvalidLoginMessage)
} else if err != nil {
if err != nil {
if models.IsNotFoundError(err) {
return oauthError("invalid_grant", InvalidLoginMessage)
}
return internalServerError("Database error querying schema").WithInternalError(err)
}

Expand Down

0 comments on commit fa21244

Please sign in to comment.