diff --git a/src/App.vue b/src/App.vue index 4dfdc27af9d079a2986cb3c6489fe62d804edac1..41975a90f162301e85b125c5f6179969cba510a9 100644 --- a/src/App.vue +++ b/src/App.vue @@ -23,8 +23,8 @@ onBeforeMount(() => { // â—ï¸ Avoid an infinite redirect to.name !== "login" ) { - // redirect the user to the login page - return { name: "login" }; + // redirect the user to the login page and preserve query params for login error message + return { name: "login", query: to.query }; } }); }); diff --git a/src/views/LoginView.vue b/src/views/LoginView.vue index 1a68764147fb333a3b6650b06641c4ff0cb2c2d2..28cfbabebe0bda4544fd14e43654edfbfd3ca21d 100644 --- a/src/views/LoginView.vue +++ b/src/views/LoginView.vue @@ -1,26 +1,67 @@ <script setup lang="ts"> -import { onBeforeMount } from "vue"; +import { onBeforeMount, onMounted } from "vue"; import { useAuthStore } from "@/stores/auth"; -import { useRouter } from "vue-router"; +import { useRouter, useRoute } from "vue-router"; import { OpenAPI } from "@/client"; +import { Toast } from "bootstrap"; const router = useRouter(); +const route = useRoute(); const store = useAuthStore(); +let errorToast: Toast | null = null; + onBeforeMount(() => { if (store.authenticated) { // If user is authenticated redirect him to the dashboard router.push({ name: "buckets" }); } }); + +onMounted(() => { + errorToast = new Toast("#loginErrorToast"); + // if there is a query param 'login_error' show the error toast + if (route.query.login_error != null) { + errorToast?.show(); + } +}); </script> <template> + <div class="toast-container position-fixed top-toast end-0 p-3"> + <div + role="alert" + aria-live="assertive" + aria-atomic="true" + class="toast text-bg-danger align-items-center border-0" + style="--bs-bg-opacity: 0.7" + data-bs-config='{"delay":8000}' + data-bs-autohide="true" + id="loginErrorToast" + > + <div class="toast-header text-bg-danger"> + <strong class="me-auto">Login Error</strong> + <button + type="button" + class="btn-close btn-close-white" + data-bs-dismiss="toast" + aria-label="Close" + ></button> + </div> + <div class="toast-body"> + <p> + There has been some kind of error during the login.<br /> + Please try again later. + </p> + <p>Error Code: {{ route.query.login_error }}</p> + </div> + </div> + </div> <div class="card text-center bg-dark ms-md-auto position-fixed top-50 start-50 translate-middle" > - <div class="card-header text-dark bg-light">LoginView</div> + <div class="card-header text-dark bg-light">S3Proxy</div> <div class="card-body p-5"> <h5 class="card-title text-light">Login</h5> <p class="card-text text-secondary">