File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -7,23 +7,11 @@ const route = useRoute()
77const { user, logout } = useAtproto ()
88
99async function handleBlueskySignIn() {
10- await navigateTo (
11- {
12- path: ' /api/auth/atproto' ,
13- query: { handle: ' https://bsky.social' , returnTo: route .fullPath },
14- },
15- { external: true },
16- )
10+ await authRedirect (' https://bsky.social' , { redirectTo: route .fullPath })
1711}
1812
1913async function handleCreateAccount() {
20- await navigateTo (
21- {
22- path: ' /api/auth/atproto' ,
23- query: { handle: ' https://npmx.social' , create: ' true' , returnTo: route .fullPath },
24- },
25- { external: true },
26- )
14+ await authRedirect (' https://npmx.social' , { create: true , redirectTo: route .fullPath })
2715}
2816
2917async function handleLogin() {
Original file line number Diff line number Diff line change 11import type { FetchError } from 'ofetch'
22import type { LocationQueryRaw } from 'vue-router'
33
4+ interface AuthRedirectOptions {
5+ create ?: boolean
6+ redirectTo ?: string
7+ }
8+
49/**
510 * Redirect user to ATProto authentication
611 */
7- export async function authRedirect ( identifier : string , create : boolean = false ) {
12+ export async function authRedirect ( identifier : string , options : AuthRedirectOptions = { } ) {
813 let query : LocationQueryRaw = { handle : identifier }
9- if ( create ) {
14+ if ( options . create ) {
1015 query = { ...query , create : 'true' }
1116 }
17+ if ( options . redirectTo ) {
18+ query = { ...query , returnTo : options . redirectTo }
19+ }
1220 await navigateTo (
1321 {
1422 path : '/api/auth/atproto' ,
You can’t perform that action at this time.
0 commit comments