dev #1
1 changed files with 10 additions and 3 deletions
|
@ -33,7 +33,7 @@
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
<div>
|
<div>
|
||||||
Already have an account? <NuxtLink href="/login">Log in</NuxtLink>!
|
Already have an account? <NuxtLink :href="loginUrl">Log in</NuxtLink>!
|
||||||
</div>
|
</div>
|
||||||
</NuxtLayout>
|
</NuxtLayout>
|
||||||
</template>
|
</template>
|
||||||
|
@ -74,7 +74,9 @@ const errorMessages = reactive({
|
||||||
|
|
||||||
//const authStore = useAuthStore();
|
//const authStore = useAuthStore();
|
||||||
const auth = useAuth();
|
const auth = useAuth();
|
||||||
const redirectTo = useRoute().query.redirect_to;
|
const query = useRoute().query as Record<string, string>;
|
||||||
|
const searchParams = new URLSearchParams(query);
|
||||||
|
const loginUrl = `/login?${searchParams}`
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
if (auth.accessToken.value) {
|
if (auth.accessToken.value) {
|
||||||
|
@ -120,7 +122,12 @@ const apiVersion = useRuntimeConfig().public.apiVersion;
|
||||||
async function register(e: Event) {
|
async function register(e: Event) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
console.log("Sending registration data");
|
console.log("Sending registration data");
|
||||||
|
try {
|
||||||
await auth.register(form.username, form.email, form.password);
|
await auth.register(form.username, form.email, form.password);
|
||||||
|
return await navigateTo(query.redirect_to);
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error registering:", error);
|
||||||
|
}
|
||||||
//return navigateTo(redirectTo ? redirectTo as string : useAppConfig().baseURL as string);
|
//return navigateTo(redirectTo ? redirectTo as string : useAppConfig().baseURL as string);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue