Skip to content

Commit

Permalink
fix: revert refactor on updateMFASessionsAndClaims (#1413)
Browse files Browse the repository at this point in the history
## What kind of change does this PR introduce?

Temporarily reverts a refactor of `updateMFASessionsAndClaims`. This
will be addressed in a separate PR

Co-authored-by: joel <[email protected]>
  • Loading branch information
J0 and joel authored Feb 9, 2024
1 parent 18cf8cd commit 279c241
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 279c241

Please sign in to comment.