feat: add support for redirect_to query param in register page
This commit is contained in:
parent
9f6490d744
commit
8bfa17631c
1 changed files with 10 additions and 3 deletions
|
@ -33,7 +33,7 @@
|
|||
</div>
|
||||
</form>
|
||||
<div>
|
||||
Already have an account? <NuxtLink href="/login">Log in</NuxtLink>!
|
||||
Already have an account? <NuxtLink :href="loginUrl">Log in</NuxtLink>!
|
||||
</div>
|
||||
</NuxtLayout>
|
||||
</template>
|
||||
|
@ -74,7 +74,9 @@ const errorMessages = reactive({
|
|||
|
||||
//const authStore = useAuthStore();
|
||||
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(() => {
|
||||
if (auth.accessToken.value) {
|
||||
|
@ -120,7 +122,12 @@ const apiVersion = useRuntimeConfig().public.apiVersion;
|
|||
async function register(e: Event) {
|
||||
e.preventDefault();
|
||||
console.log("Sending registration data");
|
||||
await auth.register(form.username, form.email, form.password);
|
||||
try {
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue