Skip to content

Commit 19a9a5f

Browse files
committed
Moved to be a bit cleaner update api
1 parent 5da9972 commit 19a9a5f

3 files changed

Lines changed: 16 additions & 10 deletions

File tree

server/api/auth/session.delete.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
export default eventHandlerWithOAuthSession(async (event, oAuthSession, serverSession) => {
2-
await Promise.all([oAuthSession?.signOut(), serverSession.clear()])
3-
2+
// Even tho the signOut also clears part of the server cache should be done in order
3+
// to let the oAuth package do any other clean up it may need
4+
await oAuthSession?.signOut()
5+
await serverSession.clear()
46
return 'Session cleared'
57
})

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,14 @@ export class OAuthSessionStore implements NodeSavedSessionStore {
1717

1818
async set(_key: string, val: NodeSavedSession) {
1919
// We are ignoring the key since the mapping is already done in the session
20-
this.session.data.oauthSession = val
21-
await this.session.update(this.session.data)
20+
await this.session.update({
21+
oauthSession: val,
22+
})
2223
}
2324

2425
async del() {
25-
this.session.data.oauthSession = undefined
26-
await this.session.update(this.session.data)
26+
await this.session.update({
27+
oauthSession: undefined,
28+
})
2729
}
2830
}

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,14 @@ export class OAuthStateStore implements NodeSavedStateStore {
1717

1818
async set(_key: string, val: NodeSavedState) {
1919
// We are ignoring the key since the mapping is already done in the session
20-
this.session.data.oauthState = val
21-
await this.session.update(this.session.data)
20+
await this.session.update({
21+
oauthState: val,
22+
})
2223
}
2324

2425
async del() {
25-
this.session.data.oauthState = undefined
26-
await this.session.update(this.session.data)
26+
await this.session.update({
27+
oauthState: undefined,
28+
})
2729
}
2830
}

0 commit comments

Comments
 (0)