Skip to content

Commit 7dbc12a

Browse files
committed
resolves setting a new session id everytime
1 parent e711766 commit 7dbc12a

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

server/utils/atproto/oauth-session-store.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,17 @@ export class OAuthSessionStore implements NodeSavedSessionStore {
3030
}
3131

3232
async set(key: string, val: NodeSavedSession) {
33-
let sessionId = crypto.randomUUID()
34-
try {
33+
const serverSessionData = this.serverSession.data
34+
let sessionId
35+
if (!serverSessionData.oauthSessionId) {
36+
sessionId = crypto.randomUUID()
3537
await this.serverSession.update({
3638
oauthSessionId: sessionId,
3739
})
40+
} else {
41+
sessionId = serverSessionData.oauthSessionId
42+
}
43+
try {
3844
await this.storage.setItem<NodeSavedSession>(this.createStorageKey(key, sessionId), val)
3945
} catch (error) {
4046
// Not sure if this has been happening. But helps with debugging

0 commit comments

Comments
 (0)