Skip to content

Commit

Permalink
fix: properly add authError query param to redirect url (#4027)
Browse files Browse the repository at this point in the history
  • Loading branch information
Trancever authored Jan 2, 2023
1 parent e9dfbcf commit 82e8b64
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/dull-rings-arrive.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@blitzjs/auth": patch
---

Fixes adding authError query param in Passport adapter.
4 changes: 3 additions & 1 deletion packages/blitz-auth/src/server/passport-adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,10 @@ export function passportAuth(config: BlitzPassportConfig): ApiHandler {
if (error) {
console.error(`Login via ${strategyName} was unsuccessful.`)
console.error(error)

const authErrorQueryStringKey = redirectUrl.includes("?") ? "&authError=" : "?authError=";
redirectUrl +=
"?authError=" + encodeURIComponent(truncateString(error.toString(), 100))
authErrorQueryStringKey + encodeURIComponent(truncateString(error.toString(), 100))
res.setHeader("Location", redirectUrl)
res.statusCode = 302
res.end()
Expand Down

0 comments on commit 82e8b64

Please sign in to comment.