Skip to content

Commit

Permalink
fix: return invalid login creds before email not confirmed (#284)
Browse files Browse the repository at this point in the history
  • Loading branch information
kangmingtay committed Nov 25, 2021
1 parent ee6027c commit 92abe18
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions api/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,16 +168,16 @@ func (a *API) ResourceOwnerPasswordGrant(ctx context.Context, w http.ResponseWri
return internalServerError("Database error querying schema").WithInternalError(err)
}

if !user.Authenticate(params.Password) {
return oauthError("invalid_grant", InvalidLoginMessage)
}

if params.Email != "" && !user.IsConfirmed() {
return oauthError("invalid_grant", "Email not confirmed")
} else if params.Phone != "" && !user.IsPhoneConfirmed() {
return oauthError("invalid_grant", "Phone not confirmed")
}

if !user.Authenticate(params.Password) {
return oauthError("invalid_grant", InvalidLoginMessage)
}

var token *AccessTokenResponse
err = a.db.Transaction(func(tx *storage.Connection) error {
var terr error
Expand Down

0 comments on commit 92abe18

Please sign in to comment.