-
-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(account)!: update authentication flow #1687
base: beta
Are you sure you want to change the base?
Changes from 32 commits
9a5ad6c
62b99d6
d505463
4a86b2b
cd65cbc
f167cc9
013980f
e488e14
691a5a9
2e91ca5
58dbc9a
97a431a
21d2920
9d8e747
6af14af
d2e2f4c
10d456f
aba3fe0
f227f0c
e57282a
65cb627
3bd5d44
15fe2fc
8e26419
b842e02
5f72daf
5d528c3
8a89c74
faa0089
59cc12c
4927602
9df88a4
5c3da72
e9839bf
510a11f
a0ba90c
43b3d60
6a4e201
2354350
41ed214
3f388fc
e872835
39d1058
4166f8f
e906d96
37809aa
b3e577b
a0f54a0
00ec0e2
a906d4f
4726b26
30260f9
727c9ef
1be2e06
79a64a1
e90f4ef
4941401
ea4b8e1
e24a7e2
ea2730d
dfebaa9
f00ae77
0ca7e74
ea9db67
68ad066
c07b891
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,15 +3,9 @@ | |
:aria-label="ariaLabel" | ||
class="justify-center rounded-md px-4 py-2 font-medium" | ||
:class=" | ||
[ | ||
...(isPrimary | ||
? [ | ||
'bg-gradient-to-tr from-blue-500 to-blue-600 text-text-bright dark:from-blue-300 dark:to-blue-400 dark:text-text-dark', | ||
] | ||
: [ | ||
'border border-gray-300 text-text-dark hover:bg-black/5 dark:border-gray-600 dark:text-text-bright dark:hover:bg-black/30', | ||
]), | ||
].join(' ') | ||
variant === 'primary' | ||
? 'bg-accent-fancy from-blue-500 to-blue-600 text-text-bright hover:bg-accent-strong dark:from-blue-300 dark:to-blue-400 dark:text-text-dark' | ||
: 'bg-accent-weak text-accent-strong hover:bg-accent-mid dark:border dark:border-gray-600 dark:bg-inherit dark:text-text-bright dark:hover:bg-black/30' | ||
" | ||
:disabled="disabled" | ||
:to="props.to" | ||
|
@@ -35,14 +29,15 @@ export interface Props { | |
ariaLabel: string | ||
disabled?: boolean | ||
isExternal?: boolean | ||
isPrimary?: boolean | ||
variant?: 'primary' | 'accent' | ||
to?: RouteLocationRaw | ||
type?: 'button' | 'reset' | 'submit' | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. empty line to be removed |
||
const props = withDefaults(defineProps<Props>(), { | ||
disabled: false, | ||
isExternal: undefined, | ||
isPrimary: true, | ||
variant: 'primary', // default variant | ||
to: undefined, | ||
type: 'button', | ||
}) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<template> | ||
<button | ||
:aria-label="ariaLabel" | ||
:class="[ | ||
'w-full justify-center rounded-md px-4 py-2 font-medium transition-colors', | ||
disabled | ||
? 'text-faint-mid cursor-not-allowed bg-faint-weak' | ||
: 'bg-accent-strong text-text-bright hover:bg-accent-mid dark:bg-accent-strong dark:text-text-dark', | ||
]" | ||
:disabled="disabled" | ||
:type="type" | ||
@click="handleSubmit" | ||
> | ||
<slot /> | ||
</button> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
export interface Props { | ||
ariaLabel: string | ||
disabled?: boolean | ||
type?: 'button' | 'reset' | 'submit' | ||
handleSubmit: () => void | ||
} | ||
|
||
defineProps<Props>() | ||
</script> |
Original file line number | Diff line number | Diff line change | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,33 @@ | ||||||||||||||||
<template> | ||||||||||||||||
<footer class="mt-auto py-8"> | ||||||||||||||||
<div class="mx-auto flex flex-row justify-center gap-x-20"> | ||||||||||||||||
<AppLink :to="localePath('legal-notice')" :is-colored="true"> | ||||||||||||||||
{{ t('terms') }} | ||||||||||||||||
</AppLink> | ||||||||||||||||
|
||||||||||||||||
<AppLink :to="localePath('index')" :is-colored="true"> | ||||||||||||||||
{{ t('imprint') }} | ||||||||||||||||
</AppLink> | ||||||||||||||||
|
||||||||||||||||
Comment on lines
+7
to
+11
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||
<AppLink :to="localePath('privacy-policy')" :is-colored="true"> | ||||||||||||||||
{{ t('policy') }} | ||||||||||||||||
</AppLink> | ||||||||||||||||
</div> | ||||||||||||||||
</footer> | ||||||||||||||||
</template> | ||||||||||||||||
|
||||||||||||||||
<script setup lang="ts"> | ||||||||||||||||
const { t } = useI18n() | ||||||||||||||||
const localePath = useLocalePath() | ||||||||||||||||
</script> | ||||||||||||||||
|
||||||||||||||||
<i18n lang="yaml"> | ||||||||||||||||
de: | ||||||||||||||||
terms: Bedingungen | ||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||
imprint: Impressum | ||||||||||||||||
policy: Datenschutzrichtlinie | ||||||||||||||||
en: | ||||||||||||||||
terms: Terms | ||||||||||||||||
imprint: Imprint | ||||||||||||||||
policy: Policy | ||||||||||||||||
</i18n> |
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
@@ -1,15 +1,5 @@ | ||||||||||
<template> | ||||||||||
<div class="flex flex-col items-center gap-4"> | ||||||||||
<ButtonColored | ||||||||||
:is-primary="false" | ||||||||||
:aria-label="t('register')" | ||||||||||
:to="localePath('session-create')" | ||||||||||
> | ||||||||||
{{ t('signIn') }} | ||||||||||
<template #prefix> | ||||||||||
<IHeroiconsArrowLeft /> | ||||||||||
</template> | ||||||||||
</ButtonColored> | ||||||||||
<Form | ||||||||||
:errors="api.errors" | ||||||||||
:errors-pg-ids="{ | ||||||||||
|
@@ -20,7 +10,7 @@ | |||||||||
form-class="w-full" | ||||||||||
:is-form-sent="isFormSent" | ||||||||||
:submit-name="t('register')" | ||||||||||
@submit.prevent="submit" | ||||||||||
@submit.prevent="handleSubmit" | ||||||||||
> | ||||||||||
<FormInputUsername | ||||||||||
:form-input="v$.username" | ||||||||||
|
@@ -47,45 +37,86 @@ | |||||||||
</FormInputStateInfo> | ||||||||||
</template> | ||||||||||
</Form> | ||||||||||
|
||||||||||
<AppLink | ||||||||||
:to="localePath('session-create')" | ||||||||||
:is-underlined="true" | ||||||||||
:is-colored="true" | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
> | ||||||||||
{{ t('alreadyHaveAnAccount') }} | ||||||||||
</AppLink> | ||||||||||
|
||||||||||
<!-- Modals --> | ||||||||||
<ModalPrivacyPolicy | ||||||||||
v-model="privacyModalOpen" | ||||||||||
@open-general-terms="openGeneralTerms" | ||||||||||
/> | ||||||||||
|
||||||||||
<ModalGeneralTerms v-model="generalTermsModalOpen" @accepted="submit" /> | ||||||||||
</div> | ||||||||||
</template> | ||||||||||
|
||||||||||
<script setup lang="ts"> | ||||||||||
import { useVuelidate } from '@vuelidate/core' | ||||||||||
import { useCreateLegalTermAcceptanceMutation } from '~~/gql/documents/mutations/account/accountLegalTermAcceptance' | ||||||||||
import { useAccountRegistrationMutation } from '~~/gql/documents/mutations/account/accountRegistration' | ||||||||||
|
||||||||||
const { locale, t } = useI18n() | ||||||||||
const localePath = useLocalePath() | ||||||||||
const fireAlert = useFireAlert() | ||||||||||
const store = useMaevsiStore() | ||||||||||
|
||||||||||
// api data | ||||||||||
const privacyModalOpen = ref(false) | ||||||||||
const generalTermsModalOpen = ref(false) | ||||||||||
|
||||||||||
const accountRegistrationMutation = useAccountRegistrationMutation() | ||||||||||
const api = getApiData([accountRegistrationMutation]) | ||||||||||
|
||||||||||
// data | ||||||||||
const form = reactive({ | ||||||||||
captcha: ref<string>(), | ||||||||||
emailAddress: ref<string>(), | ||||||||||
password: ref<string>(), | ||||||||||
username: ref<string>(), | ||||||||||
}) | ||||||||||
const isFormSent = ref(false) | ||||||||||
|
||||||||||
// methods | ||||||||||
const submit = async () => { | ||||||||||
if (!(await isFormValid({ v$, isFormSent }))) return | ||||||||||
const isFormSent = ref(false) | ||||||||||
|
||||||||||
// Methods | ||||||||||
const submit = async (termId: string) => { | ||||||||||
store.turnstileToken = form.captcha | ||||||||||
|
||||||||||
const result = await accountRegistrationMutation.executeMutation({ | ||||||||||
const accountResult = await accountRegistrationMutation.executeMutation({ | ||||||||||
emailAddress: form.emailAddress || '', | ||||||||||
language: locale.value, | ||||||||||
password: form.password || '', | ||||||||||
username: form.username || '', | ||||||||||
}) | ||||||||||
|
||||||||||
if (result.error || !result.data) return | ||||||||||
if (accountResult.error) { | ||||||||||
return | ||||||||||
} | ||||||||||
|
||||||||||
const accountUuid = accountResult.data?.accountRegistration?.uuid | ||||||||||
if (!accountUuid) { | ||||||||||
console.error('No account UUID received') | ||||||||||
return | ||||||||||
} | ||||||||||
|
||||||||||
const legalTermAcceptanceMutation = useCreateLegalTermAcceptanceMutation() | ||||||||||
|
||||||||||
const acceptanceResult = await legalTermAcceptanceMutation.executeMutation({ | ||||||||||
input: { | ||||||||||
legalTermAcceptance: { | ||||||||||
accountId: accountUuid, | ||||||||||
legalTermId: termId, | ||||||||||
}, | ||||||||||
}, | ||||||||||
}) | ||||||||||
|
||||||||||
if (acceptanceResult.error) { | ||||||||||
console.error('Legal term acceptance error:', acceptanceResult.error) | ||||||||||
return | ||||||||||
} | ||||||||||
|
||||||||||
await fireAlert({ | ||||||||||
level: 'success', | ||||||||||
|
@@ -94,6 +125,16 @@ const submit = async () => { | |||||||||
}) | ||||||||||
} | ||||||||||
|
||||||||||
const handleSubmit = async () => { | ||||||||||
if (!(await isFormValid({ v$, isFormSent }))) return | ||||||||||
|
||||||||||
privacyModalOpen.value = true | ||||||||||
} | ||||||||||
|
||||||||||
const openGeneralTerms = () => { | ||||||||||
generalTermsModalOpen.value = true | ||||||||||
} | ||||||||||
|
||||||||||
// vuelidate | ||||||||||
const rules = { | ||||||||||
captcha: VALIDATION_CAPTCHA(), | ||||||||||
|
@@ -104,6 +145,7 @@ const rules = { | |||||||||
password: VALIDATION_PASSWORD(), | ||||||||||
emailAddress: VALIDATION_EMAIL_ADDRESS({ isRequired: true }), | ||||||||||
} | ||||||||||
|
||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. empty line to be removed, it's all the |
||||||||||
const v$ = useVuelidate(rules, form) | ||||||||||
</script> | ||||||||||
|
||||||||||
|
@@ -115,13 +157,13 @@ de: | |||||||||
register: Registrieren | ||||||||||
registrationSuccessBody: Verifiziere deinen Account über den Link in der E-Mail, die du in Kürze erhalten wirst. | ||||||||||
registrationSuccessTitle: Verifizierungs-E-Mail gesendet. | ||||||||||
signIn: Stattdessen anmelden | ||||||||||
alreadyHaveAnAccount: 'Du hast bereits ein Konto? Anmelden' | ||||||||||
en: | ||||||||||
accountDeletionNotice: "You'll be able to delete your account at any time." | ||||||||||
postgres22023: Your password is too short! Think of a longer one. | ||||||||||
postgres23505: This username or email address is already in use! Think of a new name or try signing in instead. | ||||||||||
register: Register | ||||||||||
register: Sign Up | ||||||||||
registrationSuccessBody: Verify your account using the verification link sent to you by email. | ||||||||||
registrationSuccessTitle: Verification email sent. | ||||||||||
signIn: Sign in instead | ||||||||||
alreadyHaveAnAccount: Already have an account? Log in | ||||||||||
</i18n> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this work? Shouldn't it be
?