feat: pass next to sign-up / login
This commit is contained in:
parent
d161696341
commit
3c3dde74b9
|
|
@ -1,7 +1,9 @@
|
|||
<script setup lang="ts">
|
||||
import WizardPage from "@/components/onboarding/WizardPage.vue";
|
||||
import { useUserStore } from "@/stores/user";
|
||||
import { getLoginURL } from "@/router/utils";
|
||||
import { getLoginURL, getSignUpURL } from "@/router/utils";
|
||||
import { useRoute } from "vue-router";
|
||||
import { computed } from "vue";
|
||||
|
||||
const props = defineProps({
|
||||
courseType: {
|
||||
|
|
@ -9,7 +11,27 @@ const props = defineProps({
|
|||
required: true,
|
||||
},
|
||||
});
|
||||
|
||||
const user = useUserStore();
|
||||
const route = useRoute();
|
||||
|
||||
function constructParams() {
|
||||
const params: { lang: string; next?: string; course?: string } = {
|
||||
lang: user.language,
|
||||
};
|
||||
|
||||
const nextValue = route.query.next;
|
||||
if (nextValue && typeof nextValue === "string") {
|
||||
params.next = nextValue;
|
||||
} else {
|
||||
params.course = props.courseType;
|
||||
}
|
||||
|
||||
return params;
|
||||
}
|
||||
|
||||
const loginURL = computed(() => getLoginURL(constructParams()));
|
||||
const signUpURL = computed(() => getSignUpURL(constructParams()));
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
|
@ -19,23 +41,12 @@ const user = useUserStore();
|
|||
<p class="mb-4">
|
||||
{{ $t("a.Damit du myVBV nutzen kannst, brauchst du ein Konto.") }}
|
||||
</p>
|
||||
<a
|
||||
:href="`/sso/signup?course=${props.courseType}&lang=${user.language}`"
|
||||
class="btn-primary"
|
||||
>
|
||||
<a :href="signUpURL" class="btn-primary">
|
||||
{{ $t("a.Konto erstellen") }}
|
||||
</a>
|
||||
|
||||
<p class="mb-4 mt-12">{{ $t("a.Hast du schon ein Konto?") }}</p>
|
||||
<a
|
||||
:href="
|
||||
getLoginURL({
|
||||
course: props.courseType,
|
||||
lang: user.language,
|
||||
})
|
||||
"
|
||||
class="btn-secondary"
|
||||
>
|
||||
<a :href="loginURL" class="btn-secondary">
|
||||
{{ $t("a.Anmelden") }}
|
||||
</a>
|
||||
</template>
|
||||
|
|
|
|||
|
|
@ -3,15 +3,18 @@ export function shouldUseSSO() {
|
|||
return appEnv.startsWith("prod") || appEnv.startsWith("stage");
|
||||
}
|
||||
|
||||
export function getLoginURL(params = {}) {
|
||||
let url = shouldUseSSO() ? "/sso/login/" : "/login-local";
|
||||
|
||||
function constructURL(basePath: string, params = {}) {
|
||||
const queryParams = new URLSearchParams(params);
|
||||
if (queryParams.toString()) {
|
||||
url += `?${queryParams}`;
|
||||
}
|
||||
return `${basePath}${queryParams.toString() ? `?${queryParams}` : ""}`;
|
||||
}
|
||||
|
||||
return url;
|
||||
export function getLoginURL(params = {}) {
|
||||
const basePath = shouldUseSSO() ? "/sso/login" : "/login-local";
|
||||
return constructURL(basePath, params);
|
||||
}
|
||||
|
||||
export function getSignUpURL(params = {}) {
|
||||
return constructURL("/sso/signup", params);
|
||||
}
|
||||
|
||||
export function getLoginURLNext() {
|
||||
|
|
|
|||
Loading…
Reference in New Issue