Skip to content
Open
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions internal/api/recovery_codes.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func (a *API) RecoveryCodesGenerate(w http.ResponseWriter, r *http.Request) erro
}
}

if !session.IsAAL2() {
if session == nil || !session.IsAAL2() {
return apierrors.NewForbiddenError(apierrors.ErrorCodeInsufficientAAL, "AAL2 required to generate recovery codes")
}

Expand Down Expand Up @@ -201,7 +201,7 @@ func (a *API) RecoveryCodesRegenerate(w http.ResponseWriter, r *http.Request) er
return apierrors.NewUnprocessableEntityError(apierrors.ErrorCodeMFARecoveryCodesEnrollDisabled, "MFA enroll is disabled for recovery codes")
}

if !session.IsAAL2() {
if session == nil || !session.IsAAL2() {
return apierrors.NewForbiddenError(apierrors.ErrorCodeInsufficientAAL, "AAL2 required to regenerate recovery codes")
}

Expand Down
4 changes: 2 additions & 2 deletions internal/api/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func (a *API) UserUpdate(w http.ResponseWriter, r *http.Request) error {
}
}

if user.HasMFAEnabled() && !session.IsAAL2() {
if user.HasMFAEnabled() && (session == nil || !session.IsAAL2()) {
if (params.Password != nil && *params.Password != "") || (params.Email != "" && user.GetEmail() != params.Email) || (params.Phone != "" && user.GetPhone() != params.Phone) {
return apierrors.NewHTTPError(http.StatusUnauthorized, apierrors.ErrorCodeInsufficientAAL, "AAL2 session is required to update email or password when MFA is enabled.")
}
Expand Down Expand Up @@ -172,7 +172,7 @@ func (a *API) UserUpdate(w http.ResponseWriter, r *http.Request) error {
// current password required when updating password
if config.Security.UpdatePasswordRequireCurrentPassword {
// ensure user is not in a password recovery flow
if !session.IsRecovery() {
if session == nil || !session.IsRecovery() {
if params.CurrentPassword == nil || *params.CurrentPassword == "" {
return apierrors.NewBadRequestError(apierrors.ErrorCodeCurrentPasswordRequired, "Current password required when setting new password.")
}
Expand Down