Skip to content
Snippets Groups Projects
Verified Commit b35a8fb3 authored by Daniel Göbel's avatar Daniel Göbel
Browse files

Handle invitation links

parent b5b61432
No related branches found
No related tags found
1 merge request!118Resolve "Handle invitation links"
This commit is part of merge request !118. Comments created here will be created in the context of that merge request.
...@@ -31,8 +31,9 @@ const router = createRouter({ ...@@ -31,8 +31,9 @@ const router = createRouter({
title: "Login", title: "Login",
}, },
props: (route) => ({ props: (route) => ({
returnPath: route.query.return_path ?? undefined, returnPath: route.query.next ?? undefined,
loginError: route.query.login_error ?? undefined, loginError: route.query.login_error ?? undefined,
invitationToken: route.query.invitation_token ?? undefined,
}), }),
}, },
{ {
......
...@@ -11,6 +11,7 @@ const router = useRouter(); ...@@ -11,6 +11,7 @@ const router = useRouter();
const props = defineProps<{ const props = defineProps<{
returnPath?: string; returnPath?: string;
loginError?: string; loginError?: string;
invitationToken?: string;
}>(); }>();
const store = useUserStore(); const store = useUserStore();
...@@ -24,9 +25,17 @@ onBeforeMount(() => { ...@@ -24,9 +25,17 @@ onBeforeMount(() => {
} }
}); });
const returnPathQuery = computed<string>(() => const loginPath = computed<string>(() => {
props.returnPath ? `&next=${encodeURI(props.returnPath)}` : "", const loginUrl = new URL(`${OpenAPI.BASE}/auth/login?provider=lifescience`);
); console.log(props);
if (props.returnPath) {
loginUrl.searchParams.append("next", encodeURI(props.returnPath));
}
if (props.invitationToken) {
loginUrl.searchParams.append("invitation_token", props.invitationToken);
}
return loginUrl.href;
});
onMounted(() => { onMounted(() => {
errorToast = new Toast("#loginErrorToast"); errorToast = new Toast("#loginErrorToast");
...@@ -69,15 +78,16 @@ onMounted(() => { ...@@ -69,15 +78,16 @@ onMounted(() => {
<div <div
class="card text-center ms-md-auto position-fixed top-50 start-50 translate-middle shadow" class="card text-center ms-md-auto position-fixed top-50 start-50 translate-middle shadow"
> >
<div class="card-header">Login</div> <div v-if="invitationToken" class="card-header">Invitation</div>
<div v-else class="card-header">Login</div>
<div class="card-body"> <div class="card-body">
<p class="card-text text-secondary"> <p v-if="invitationToken" class="card-text text-secondary">
Connect your CloWM account with your LifeScience account
</p>
<p v-else class="card-text text-secondary">
Login to this service with LifeScience Login to this service with LifeScience
</p> </p>
<a <a :href="loginPath" class="m-2">
:href="`${OpenAPI.BASE}/auth/login?provider=lifescience${returnPathQuery}`"
class="m-2"
>
<img src="/src/assets/images/ls-login.png" alt="[LS Login]" /> <img src="/src/assets/images/ls-login.png" alt="[LS Login]" />
</a> </a>
</div> </div>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment