Skip to content

Commit

Permalink
fix: Fix login success redirect status (#542)
Browse files Browse the repository at this point in the history
* Fix login success redirect status

* Update login test
  • Loading branch information
Suzanne Rozier authored Mar 2, 2022
1 parent d927a1b commit 17b31ee
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/__tests__/pages/api/auth/[[...action]].test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ describe('API / Auth handlers', () => {
url: '/api/auth/login',
test: async ({ fetch }) => {
const res = await fetch({ method: 'POST', redirect: 'manual' })
expect(res.status).toBe(307)
expect(res.status).toBe(302)
expect(res.cookies).toStrictEqual([
expect.objectContaining({ sid: expect.any(String) }),
])
Expand Down
7 changes: 5 additions & 2 deletions src/pages/api/auth/[[...action]].ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,13 @@ handler.get('/api/auth/login', passport.authenticate('saml'))
handler.post(
'/api/auth/login',
passport.authenticate('saml', {
successRedirect: '/',
failureRedirect: '/login',
failureMessage: true,
})
}),
function (req, res) {
// Login was successful, redirect back home
res.redirect(302, '/')
}
)

// GET /api/auth/logout - initiate a SLO (logout) request
Expand Down

0 comments on commit 17b31ee

Please sign in to comment.