Skip to content

Commit

Permalink
fix: update error codes
Browse files Browse the repository at this point in the history
  • Loading branch information
joel authored and joel committed Feb 9, 2024
1 parent 18cf8cd commit 18e9dbd
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions internal/api/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -433,9 +433,17 @@ func (a *API) updateMFASessionAndClaims(r *http.Request, tx *storage.Connection,
var tokenString string
var expiresAt int64
var refreshToken *models.RefreshToken
session := getSession(ctx)
err := tx.Transaction(func(tx *storage.Connection) error {
if terr := models.AddClaimToSession(tx, session.ID, authenticationMethod); terr != nil {
currentClaims := getClaims(ctx)
sessionId, err := uuid.FromString(currentClaims.SessionId)
if err != nil {
return nil, internalServerError("Cannot read SessionId claim as UUID").WithInternalError(err)
}
err = tx.Transaction(func(tx *storage.Connection) error {
if terr := models.AddClaimToSession(tx, sessionId, authenticationMethod); terr != nil {
return terr
}
session, terr := models.FindSessionByID(tx, sessionId, false)
if terr != nil {
return terr
}
currentToken, terr := models.FindTokenBySessionID(tx, &session.ID)
Expand All @@ -458,8 +466,8 @@ func (a *API) updateMFASessionAndClaims(r *http.Request, tx *storage.Connection,
if err := session.UpdateAssociatedAAL(tx, aal); err != nil {
return err
}
tokenString, expiresAt, terr = a.generateAccessToken(ctx, tx, user, &sessionId, models.TOTPSignIn)

tokenString, expiresAt, terr = a.generateAccessToken(ctx, tx, user, &session.ID, models.TOTPSignIn)
if terr != nil {
httpErr, ok := terr.(*HTTPError)
if ok {
Expand Down

0 comments on commit 18e9dbd

Please sign in to comment.