Skip to content

Commit

Permalink
fix: do not always redirect back to settings on mfa
Browse files Browse the repository at this point in the history
  • Loading branch information
Benehiko committed Jun 16, 2023
1 parent 30b6f63 commit f3aaa0e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
9 changes: 7 additions & 2 deletions selfservice/flow/settings/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,13 @@ func (h *Handler) createBrowserSettingsFlow(w http.ResponseWriter, r *http.Reque
return
}

requestURL := x.RequestURL(r).String()
if err := h.d.SessionManager().DoesSessionSatisfy(r, s, h.d.Config().SelfServiceSettingsRequiredAAL(r.Context()), session.WithRequestURL(requestURL)); err != nil {
var managerOptions []session.ManagerOptions
requestURL := x.RequestURL(r)
if requestURL.Query().Get("return_to") != "" {
managerOptions = append(managerOptions, session.WithRequestURL(requestURL.String()))
}

if err := h.d.SessionManager().DoesSessionSatisfy(r, s, h.d.Config().SelfServiceSettingsRequiredAAL(r.Context()), managerOptions...); err != nil {
h.d.SettingsFlowErrorHandler().WriteFlowError(w, r, node.DefaultGroup, nil, nil, err)
return
}
Expand Down
10 changes: 5 additions & 5 deletions test/e2e/cypress/integration/profiles/mfa/totp.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ context("2FA TOTP", () => {
cy.visit(settings)
cy.requireStrictAal()

let secret
let secret: string
cy.get('[data-testid="node/text/totp_secret_key/text"]').then(($e) => {
secret = $e.text().trim()
})
Expand Down Expand Up @@ -101,7 +101,7 @@ context("2FA TOTP", () => {
cy.visit(settings)
cy.requireStrictAal()

let secret
let secret: string
cy.get('[data-testid="node/text/totp_secret_key/text"]').then(($e) => {
secret = $e.text().trim()
})
Expand Down Expand Up @@ -147,7 +147,7 @@ context("2FA TOTP", () => {
cy.get('img[data-testid="node/image/totp_qr"]').should("exist")

// Set up TOTP
let secret
let secret: string
cy.get('[data-testid="node/text/totp_secret_key/text"]').then(($e) => {
secret = $e.text().trim()
})
Expand Down Expand Up @@ -206,7 +206,7 @@ context("2FA TOTP", () => {

// Linking a new device works
cy.visit(settings)
let newSecret
let newSecret: string
cy.get('[data-testid="node/text/totp_secret_key/text"]').then(($e) => {
newSecret = $e.text().trim()
})
Expand Down Expand Up @@ -300,7 +300,7 @@ context("2FA TOTP", () => {
cy.get('*[name="method"][value="profile"]').click()
cy.expectSettingsSaved()

let secret
let secret: string
cy.get('[data-testid="node/text/totp_secret_key/text"]').then(($e) => {
secret = $e.text().trim()
})
Expand Down

0 comments on commit f3aaa0e

Please sign in to comment.