2024-08-25 13:37:23 +02:00
|
|
|
<template>
|
|
|
|
<div class="grow flex items-center justify-center py-12 px-4 sm:px-6 lg:px-8">
|
|
|
|
<div class="max-w-md w-full space-y-8 pb-20">
|
|
|
|
<div class="flex flex-col items-center gap-4">
|
2025-04-24 16:49:14 +02:00
|
|
|
<AppLogo />
|
2024-11-23 12:11:26 +01:00
|
|
|
<h2 class="text-center text-4xl font-extrabold text-gray-900">Einrichtung</h2>
|
2024-08-25 13:37:23 +02:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<div v-if="verification == 'loading'" class="flex flex-col gap-2 items-center">
|
|
|
|
<p class="w-fit">Einrichtungslink wird verifiziert</p>
|
|
|
|
<Spinner class="my-auto" />
|
|
|
|
</div>
|
|
|
|
<div v-else-if="verification == 'failed'" class="flex flex-col gap-2 items-center">
|
|
|
|
<p class="w-fit">Einrichtungslink nicht gültig</p>
|
|
|
|
<RouterLink to="/setup" class="text-primary">Zum Einrichtungsstart</RouterLink>
|
|
|
|
</div>
|
|
|
|
<form v-else class="flex flex-col gap-2" @submit.prevent="setup">
|
2024-08-25 18:08:05 +02:00
|
|
|
<img :src="image" alt="totp" class="w-56 h-56 self-center" />
|
|
|
|
|
2025-01-09 12:48:09 +01:00
|
|
|
<TextCopy :copyText="otp" />
|
2024-08-25 18:08:05 +02:00
|
|
|
|
2024-08-25 13:37:23 +02:00
|
|
|
<div class="-space-y-px">
|
|
|
|
<div>
|
|
|
|
<input id="totp" name="totp" type="text" required placeholder="TOTP" />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="flex flex-row gap-2">
|
|
|
|
<button type="submit" primary :disabled="setupStatus == 'loading' || setupStatus == 'success'">
|
|
|
|
Admin-Account fertigstellen
|
|
|
|
</button>
|
|
|
|
<Spinner v-if="setupStatus == 'loading'" class="my-auto" />
|
|
|
|
<SuccessCheckmark v-else-if="setupStatus == 'success'" />
|
|
|
|
<FailureXMark v-else-if="setupStatus == 'failed'" />
|
|
|
|
</div>
|
|
|
|
<p v-if="setupError" class="text-center">{{ setupError }}</p>
|
|
|
|
<RouterLink to="/setup" class="text-primary self-end">Zum Einrichtungsstart</RouterLink>
|
|
|
|
</form>
|
|
|
|
|
2024-11-23 12:11:26 +01:00
|
|
|
<FormBottomBar />
|
2024-08-25 13:37:23 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
|
import { defineComponent } from "vue";
|
|
|
|
import Spinner from "@/components/Spinner.vue";
|
|
|
|
import SuccessCheckmark from "@/components/SuccessCheckmark.vue";
|
|
|
|
import FailureXMark from "@/components/FailureXMark.vue";
|
|
|
|
import { RouterLink } from "vue-router";
|
2024-11-23 12:11:26 +01:00
|
|
|
import FormBottomBar from "@/components/FormBottomBar.vue";
|
2025-01-09 12:48:09 +01:00
|
|
|
import TextCopy from "@/components/TextCopy.vue";
|
2025-04-24 16:49:14 +02:00
|
|
|
import AppLogo from "@/components/AppLogo.vue";
|
2024-08-25 13:37:23 +02:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
export default defineComponent({
|
|
|
|
props: {
|
|
|
|
token: String,
|
|
|
|
mail: String,
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
2024-08-25 18:08:05 +02:00
|
|
|
verification: "loading" as "success" | "loading" | "failed",
|
|
|
|
image: undefined as undefined | string,
|
|
|
|
otp: undefined as undefined | string,
|
2024-08-25 13:37:23 +02:00
|
|
|
setupStatus: undefined as undefined | "loading" | "success" | "failed",
|
|
|
|
setupError: "" as string,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
this.$http
|
|
|
|
.post(`/setup/verify`, {
|
|
|
|
token: this.token,
|
|
|
|
mail: this.mail,
|
|
|
|
})
|
|
|
|
.then((result) => {
|
|
|
|
setTimeout(() => {
|
2024-08-25 18:08:05 +02:00
|
|
|
this.verification = "success";
|
|
|
|
this.image = result.data.dataUrl;
|
|
|
|
this.otp = result.data.otp;
|
2024-08-25 13:37:23 +02:00
|
|
|
}, 1000);
|
|
|
|
})
|
|
|
|
.catch((err) => {
|
|
|
|
setTimeout(() => {
|
|
|
|
this.verification = "failed";
|
|
|
|
}, 1000);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
setup(e: any) {
|
|
|
|
let formData = e.target.elements;
|
|
|
|
this.setupStatus = "loading";
|
|
|
|
this.setupError = "";
|
|
|
|
this.$http
|
2025-04-25 08:18:27 +02:00
|
|
|
.post(`/setup/finish`, {
|
2024-08-25 13:37:23 +02:00
|
|
|
token: this.token,
|
|
|
|
mail: this.mail,
|
|
|
|
totp: formData.totp.value,
|
|
|
|
})
|
|
|
|
.then((result) => {
|
|
|
|
this.setupStatus = "success";
|
|
|
|
localStorage.setItem("accessToken", result.data.accessToken);
|
|
|
|
localStorage.setItem("refreshToken", result.data.refreshToken);
|
|
|
|
setTimeout(() => {
|
|
|
|
this.$router.push(`/admin`);
|
|
|
|
}, 1000);
|
|
|
|
})
|
|
|
|
.catch((err) => {
|
|
|
|
this.setupStatus = "failed";
|
|
|
|
this.setupError = err.response.data;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
</script>
|