Skip to content

Commit 3cb43b5

Browse files
committed
chore: revert this bit
1 parent a66f535 commit 3cb43b5

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

server/api/auth/atproto.get.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export default defineEventHandler(async event => {
6969

7070
if (!query.code) {
7171
// Validate returnTo is a safe relative path (prevent open redirect)
72-
// Store in session on initial auth request, not the callback
72+
// Only set cookie on initial auth request, not the callback
7373
let redirectPath = '/'
7474
try {
7575
const clientOrigin = new URL(clientUri).origin
@@ -81,7 +81,12 @@ export default defineEventHandler(async event => {
8181
// Invalid URL, fall back to root
8282
}
8383

84-
await session.update({ returnTo: redirectPath })
84+
setCookie(event, 'auth_return_to', redirectPath, {
85+
maxAge: 60 * 5,
86+
httpOnly: true,
87+
// secure only if NOT in dev mode
88+
secure: !import.meta.dev,
89+
})
8590
try {
8691
const handle = query.handle?.toString()
8792
const create = query.create?.toString()
@@ -143,8 +148,8 @@ export default defineEventHandler(async event => {
143148
})
144149
}
145150

146-
const returnToURL = session.data.returnTo || '/'
147-
await session.update({ returnTo: undefined })
151+
const returnToURL = getCookie(event, 'auth_return_to') || '/'
152+
deleteCookie(event, 'auth_return_to')
148153

149154
return sendRedirect(event, returnToURL)
150155
})

shared/types/userSession.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,4 @@ export interface UserServerSession {
1212
// multiple did logins per server session
1313
oauthSession: NodeSavedSession | undefined
1414
oauthState: NodeSavedState | undefined
15-
// Temporary storage for post-auth redirect path during OAuth flow
16-
returnTo?: string
1715
}

0 commit comments

Comments
 (0)