an app to share curated trails sidetrail.app
atproto nextjs react rsc
50
fork

Configure Feed

Select the types of activity you want to include in your feed.

move redirect out of try so it does not get caught

+10 -13
+10 -13
auth/actions.ts
··· 7 7 export async function login(formData: FormData) { 8 8 const rawHandle = formData.get("loginHint") as string; 9 9 let returnUrl = (formData.get("returnUrl") as string) || "/"; 10 - if (!returnUrl.startsWith('/')) { 11 - returnUrl = '/' 10 + if (!returnUrl.startsWith("/")) { 11 + returnUrl = "/"; 12 12 } 13 13 14 14 const handle = rawHandle?.trim().replace(/^@/, ""); 15 - 16 15 if (!handle) { 17 16 redirect("/login?error=" + encodeURIComponent("Please enter your handle")); 18 17 } 19 18 20 19 let authorizationUrl: string; 21 - 22 20 try { 23 21 const client = await getOAuthClient(); 24 - 25 - const url = await client.authorize(handle, { 26 - scope: "atproto transition:generic", 27 - state: JSON.stringify({ returnUrl }), 28 - }); 29 - 30 - authorizationUrl = url.toString(); 31 - redirect(authorizationUrl); 22 + authorizationUrl = ( 23 + await client.authorize(handle, { 24 + scope: "atproto transition:generic", 25 + state: JSON.stringify({ returnUrl }), 26 + }) 27 + ).toString(); 32 28 } catch (error) { 33 29 console.error("OAuth authorize error:", error); 34 30 const message = error instanceof Error ? error.message : "Unknown error"; 35 31 redirect("/login?error=" + encodeURIComponent(`Login failed: ${message}`)); 36 - } 32 + } 33 + redirect(authorizationUrl); 37 34 } 38 35 39 36 export async function logout(returnUrl: string = "/") {