Skip to content

Commit fb34be2

Browse files
committed
type the minidoc response
1 parent 19a9a5f commit fb34be2

1 file changed

Lines changed: 8 additions & 10 deletions

File tree

server/api/auth/atproto.get.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import { NodeOAuthClient } from '@atproto/oauth-client-node'
33
import { createError, getQuery, sendRedirect } from 'h3'
44
import { useOAuthStorage } from '#server/utils/atproto/storage'
55
import { SLINGSHOT_HOST } from '#shared/utils/constants'
6-
import { useServerSession } from '~~/server/utils/server-session'
6+
import { useServerSession } from '#server/utils/server-session'
7+
import type { PublicUserSession } from '#shared/schemas/publicUserSession'
78

89
export default defineEventHandler(async event => {
910
const config = useRuntimeConfig(event)
@@ -53,15 +54,12 @@ export default defineEventHandler(async event => {
5354
`https://${SLINGSHOT_HOST}/xrpc/com.bad-example.identity.resolveMiniDoc?identifier=${agent.did}`,
5455
{ headers: { 'User-Agent': 'npmx' } },
5556
)
56-
const miniDoc = await response.json()
57-
58-
await session.update({
59-
public: {
60-
did: miniDoc.did,
61-
handle: miniDoc.handle,
62-
pds: miniDoc.pds,
63-
},
64-
})
57+
if (response.ok) {
58+
const miniDoc: PublicUserSession = await response.json()
59+
await session.update({
60+
public: miniDoc,
61+
})
62+
}
6563

6664
return sendRedirect(event, '/')
6765
})

0 commit comments

Comments
 (0)