-
Notifications
You must be signed in to change notification settings - Fork 0
feat(oauth): show account choices for returning users #36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -100,18 +100,23 @@ export async function GET(request: NextRequest) { | |
| const session = await getSession(); | ||
| if (!session.isLoggedIn || !session.userId) { | ||
| // Store OAuth params in session and redirect to login | ||
| // Add fresh_login flag so we skip account selection after login | ||
| const loginUrl = new URL("/login", request.url); | ||
| const redirectParams = new URLSearchParams(searchParams.toString()); | ||
| redirectParams.set("fresh_login", "true"); | ||
| loginUrl.searchParams.set( | ||
| "redirect", | ||
| `/api/oauth/authorize?${searchParams.toString()}` | ||
| `/api/oauth/authorize?${redirectParams.toString()}` | ||
| ); | ||
| return NextResponse.redirect(loginUrl); | ||
| } | ||
|
|
||
| // If user is already signed in and hasn't confirmed their account, | ||
| // redirect to account selection page | ||
| // redirect to account selection page. | ||
| // Skip account selection if user just logged in (fresh_login=true) | ||
| const accountConfirmed = searchParams.get("account_confirmed"); | ||
| if (!accountConfirmed) { | ||
| const freshLogin = searchParams.get("fresh_login"); | ||
| if (!accountConfirmed && !freshLogin) { | ||
|
Comment on lines
117
to
+119
|
||
| const accountSelectUrl = new URL("/oauth/account-select", request.url); | ||
| accountSelectUrl.searchParams.set("client_id", client_id); | ||
| accountSelectUrl.searchParams.set("redirect_uri", redirect_uri); | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,124 @@ | ||||||
| import { test, expect } from "@playwright/test"; | ||||||
|
|
||||||
| const ADMIN_PASSWORD = "e2e-test-admin-password"; | ||||||
|
|
||||||
| test.describe("OAuth Account Selection", () => { | ||||||
| let clientId: string; | ||||||
|
|
||||||
| test.beforeAll(async ({ browser }, testInfo) => { | ||||||
|
||||||
| test.beforeAll(async ({ browser }, testInfo) => { | |
| test.beforeAll(async ({ browser }) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
redirectquery param here is not URL-encoded, so the&characters fromsearchParams.toString()will be parsed as separate/loginquery params andredirectwill be truncated. Build the login URL withnew URL()/URLSearchParamsor at leastencodeURIComponent(/api/oauth/authorize?${...})when settingredirect.