-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: social sign up and welcome page
Co-authored-by: CrackThrough <[email protected]>
- Loading branch information
1 parent
73119fb
commit 13e3947
Showing
19 changed files
with
249 additions
and
108 deletions.
There are no files selected for viewing
Submodule assets
updated
5 files
+0 −5 | locales/en/sign-up-email.ftl | |
+13 −2 | locales/en/sign-up.ftl | |
+1 −0 | locales/ko/form.ftl | |
+4 −0 | locales/ko/sign-up-email.ftl | |
+1 −0 | locales/ko/sign-up.ftl |
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 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 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 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,21 @@ | ||
import { superValidate } from 'sveltekit-superforms/client'; | ||
import type { Actions, PageServerLoad } from './$types'; | ||
import { schema } from './_schema'; | ||
import { fail } from '@sveltejs/kit'; | ||
|
||
export const load: PageServerLoad = async () => { | ||
return { | ||
minimalFooter: true, | ||
form: await superValidate(schema) | ||
}; | ||
}; | ||
|
||
export const actions: Actions = { | ||
default: async ({ request }) => { | ||
const form = await superValidate(request, schema); | ||
|
||
if (!form.valid) return fail(400, { form }); | ||
|
||
console.log(form.data); | ||
} | ||
}; |
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 |
---|---|---|
@@ -1,117 +1,92 @@ | ||
<script lang="ts"> | ||
import AuthTitle from '@/components/atoms/auth/AuthTitle.svelte'; | ||
import Translation from '@/components/utils/Translation.svelte'; | ||
import Hint from '@/components/atoms/form/Hint.svelte'; | ||
import { setForm } from '@/utils/forms'; | ||
import Button from '@atoms/interaction/Button.svelte'; | ||
import CheckboxWithLinkedLabel from '@molecules/auth/CheckboxWithLinkedLabel.svelte'; | ||
import OAuth2SignOptions from '@molecules/auth/OAuth2SignOptions.svelte'; | ||
import { goto } from '$app/navigation'; | ||
import type { PageData } from './$types'; | ||
import { schema } from './_schema'; | ||
import FormControl from '@/components/molecules/form/FormControl.svelte'; | ||
import InputField from '@/components/atoms/interaction/InputField.svelte'; | ||
let agreeTos = false; | ||
let agreePrivacy = false; | ||
export let data: PageData; | ||
$: legalAgreements = [agreeTos, agreePrivacy]; | ||
let signupFailed = false; | ||
let validationResultViaCheckboxUpdate = false; | ||
const validate = (updateSignupFailed = true) => { | ||
const result = legalAgreements.every((agreement) => agreement); | ||
if (updateSignupFailed) signupFailed = !result; | ||
return result; | ||
}; | ||
const onCheckboxUpdate = () => { | ||
validationResultViaCheckboxUpdate = validate(false); | ||
}; | ||
const emailSignup = () => { | ||
if (!validate()) return; | ||
return goto('/auth/signup/email'); | ||
}; | ||
const googleSignup = () => { | ||
if (!validate()) return; | ||
// TODO implement after social login is implemented in backend | ||
throw new Error('Not implemented'); | ||
}; | ||
const discordSignup = () => { | ||
if (!validate()) return; | ||
// TODO implement after social login is implemented in backend | ||
throw new Error('Not implemented'); | ||
}; | ||
const { form, enhance } = setForm(data.form, { validators: schema }); | ||
</script> | ||
|
||
<AuthTitle> | ||
<Translation key="sign-up:title" /> | ||
</AuthTitle> | ||
|
||
<!-- register form --> | ||
<div class="legal-agreement-terms-group"> | ||
<h3> | ||
<Translation key="sign-up:section-terms" /> | ||
</h3> | ||
<div class="legal-agreement-container"> | ||
<CheckboxWithLinkedLabel | ||
labelKey="sign-up:terms-agreement" | ||
extraLabelKey="sign-up:terms-link" | ||
extraLabelLink="../docs/terms" | ||
bind:checked={agreeTos} | ||
onChange={onCheckboxUpdate} | ||
<form class="form-fields" method="POST" use:enhance> | ||
<FormControl name="email" labelKey="sign-up:form-email"> | ||
<InputField | ||
name="email" | ||
type="email" | ||
placeholder="sign-up:form-email-placeholder" | ||
bind:value={$form.email} | ||
/> | ||
</FormControl> | ||
<FormControl name="username" labelKey="sign-up:form-username"> | ||
<InputField | ||
name="username" | ||
type="text" | ||
placeholder="sign-up:form-username-placeholder" | ||
bind:value={$form.username} | ||
/> | ||
<CheckboxWithLinkedLabel | ||
labelKey="sign-up:privacy-agreement" | ||
extraLabelKey="sign-up:privacy-link" | ||
extraLabelLink="../docs/privacy" | ||
bind:checked={agreePrivacy} | ||
onChange={onCheckboxUpdate} | ||
</FormControl> | ||
<FormControl name="password" labelKey="sign-up:form-password"> | ||
<InputField | ||
name="password" | ||
type="password" | ||
placeholder="sign-up:form-password-placeholder" | ||
bind:value={$form.password} | ||
/> | ||
</FormControl> | ||
<FormControl name="confirmPassword" labelKey="sign-up:form-password-confirm"> | ||
<InputField | ||
name="confirmPassword" | ||
type="password" | ||
placeholder="sign-up:form-password-confirm-placeholder" | ||
bind:value={$form.confirmPassword} | ||
/> | ||
</FormControl> | ||
|
||
<!-- register form --> | ||
<div class="submit-area"> | ||
<Button type="authActionAccent" htmlType="submit"> | ||
<Translation key="sign-up:strategy-email" /> | ||
</Button> | ||
<div class="condition-disclaimer"> | ||
<Translation key="sign-up:conditions-disclaimer" allowLinks /> | ||
</div> | ||
</div> | ||
{#if signupFailed && !validationResultViaCheckboxUpdate} | ||
<Hint variant="error"> | ||
<Translation key="sign-up:error-agreement-required" /> | ||
</Hint> | ||
{/if} | ||
</div> | ||
<Button type="authActionAccent" on:click={emailSignup}> | ||
<Translation key="sign-up:strategy-email" /> | ||
</Button> | ||
</form> | ||
|
||
<!-- oauth2 register buttons --> | ||
<OAuth2SignOptions | ||
labelKey="sign-up:more-options" | ||
on:googleSignup={googleSignup} | ||
on:discordSignup={discordSignup} | ||
providerLinks={{ | ||
discord: '/auth/signup/discord', | ||
google: '/auth/signup/google' | ||
}} | ||
/> | ||
|
||
<style lang="scss"> | ||
.legal-agreement-terms-group { | ||
.form-fields { | ||
display: flex; | ||
flex-direction: column; | ||
gap: 12px; | ||
align-items: flex-start; | ||
align-self: stretch; | ||
justify-content: center; | ||
> h3 { | ||
font-weight: 700; | ||
font-style: normal; | ||
font-size: 16px; | ||
line-height: 1.2; | ||
} | ||
gap: 32px; | ||
} | ||
.legal-agreement-container { | ||
.submit-area { | ||
display: flex; | ||
flex-direction: column; | ||
gap: 12px; | ||
align-items: flex-start; | ||
align-self: stretch; | ||
} | ||
.condition-disclaimer { | ||
margin-top: 8px; | ||
color: rgba(255, 255, 255, 0.6); | ||
font-size: 14px; | ||
} | ||
</style> |
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,32 @@ | ||
import { error, fail } from '@sveltejs/kit'; | ||
import type { Actions, PageServerLoad } from './$types'; | ||
import { superValidate } from 'sveltekit-superforms/client'; | ||
import { schema } from './_schema'; | ||
|
||
const providers = ['google', 'discord'] as const; | ||
|
||
type ProviderName = (typeof providers)[number]; | ||
|
||
const providerNames: Record<ProviderName, string> = { | ||
google: 'Google', | ||
discord: 'Discord' | ||
}; | ||
|
||
export const load: PageServerLoad = async ({ params: { provider } }) => { | ||
if (!(providers as unknown as string[]).includes(provider)) | ||
return error(404, { message: 'Not found' }); | ||
|
||
return { | ||
provider, | ||
providerName: providerNames[provider as ProviderName], | ||
form: await superValidate(schema) | ||
}; | ||
}; | ||
|
||
export const actions: Actions = { | ||
default: async ({ request }) => { | ||
const form = await superValidate(request, schema); | ||
|
||
if (!form.valid) return fail(400, { form }); | ||
} | ||
}; |
Oops, something went wrong.