-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #108 from ThatConference/cs/signup
refactor: two signup pages in favor of form actions
- Loading branch information
Showing
5 changed files
with
75 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { redirect, error } from '@sveltejs/kit'; | ||
import * as Sentry from '@sentry/sveltekit'; | ||
|
||
export const actions = { | ||
default: async ({ locals, fetch }) => { | ||
let _url = '/'; | ||
try { | ||
const session = await locals.getSession(); | ||
if (!session?.user) { | ||
const tokenCall = await fetch('/auth/csrf'); | ||
const csrfTokenResponse = await new Response(tokenCall.body).json(); | ||
const csrfToken = csrfTokenResponse.csrfToken; | ||
|
||
const qparams = new URLSearchParams(); | ||
qparams.append('screen_hint', 'signup'); | ||
|
||
const formData = new URLSearchParams(); | ||
formData.append('redirect', 'false'); | ||
formData.append('csrfToken', csrfToken); | ||
formData.append('callbackUrl', '/my/profiles'); | ||
|
||
const signInRequest = await fetch('/auth/signin/auth0?' + qparams.toString(), { | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/x-www-form-urlencoded', | ||
'X-Auth-Return-Redirect': '1' | ||
}, | ||
body: formData.toString() | ||
}); | ||
|
||
const signInResponse = await new Response(signInRequest.body).json(); | ||
if (signInResponse?.url) { | ||
_url = signInResponse.url; | ||
} | ||
} | ||
} catch (err) { | ||
Sentry.setContext('error', { err }); | ||
throw error(500, 'Authentication Sign-up Error'); | ||
} | ||
|
||
if (_url) { | ||
throw redirect(302, _url); | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters