Skip to content

Commit

Permalink
Add reset password route
Browse files Browse the repository at this point in the history
  • Loading branch information
laperlej committed Jun 28, 2024
1 parent 414bc64 commit 5bb2935
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 16 deletions.
18 changes: 2 additions & 16 deletions client/src/components/Login/LoginForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ async function submitLogin() {
}
if (response.data.expired_user) {
window.location.href = withPrefix(`/root/login?expired_user=${response.data.expired_user}`);
window.location.href = withPrefix(`/login/start?expired_user=${response.data.expired_user}`);
} else if (connectExternalProvider.value) {
window.location.href = withPrefix("/user/external_ids?connect_external=true");
} else if (response.data.redirect) {
Expand Down Expand Up @@ -125,20 +125,6 @@ function setRedirect(url: string) {
localStorage.setItem("redirect_url", url);
}
async function resetLogin() {
loading.value = true;
try {
const response = await axios.post(withPrefix("/user/reset_password"), { email: login.value });
messageVariant.value = "info";
messageText.value = response.data.message;
} catch (e) {
messageVariant.value = "danger";
messageText.value = errorMessageAsString(e, "Password reset failed for an unknown reason.");
} finally {
loading.value = false;
}
}
function returnToLogin() {
router.push("/login/start");
}
Expand Down Expand Up @@ -205,7 +191,7 @@ function returnToLogin() {
v-localize
href="javascript:void(0)"
role="button"
@click.prevent="resetLogin">
@click.prevent="router.push('/login/reset_password')">
Click here to reset your password.
</a>
</BFormText>
Expand Down
47 changes: 47 additions & 0 deletions client/src/entry/analysis/modules/ResetPassword.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<script setup lang="ts">
import axios from "axios";
import { BAlert, BButton, BCard, BForm, BFormGroup, BFormInput } from "bootstrap-vue";
import { ref } from "vue";
import { withPrefix } from "@/utils/redirect";
import { errorMessageAsString } from "@/utils/simple-error";
const loading = ref(false);
const email = ref("");
const message = ref("");
const messageVariant = ref("info");
async function resetLogin() {
loading.value = true;
try {
const response = await axios.post(withPrefix("/user/reset_password"), { email: email.value });
messageVariant.value = "info";
message.value = response.data.message;
} catch (e) {
messageVariant.value = "danger";
message.value = errorMessageAsString(e, "Password reset failed for an unknown reason.");
} finally {
loading.value = false;
}
}
</script>

<template>
<div class="container">
<div class="justify-content-md-center">
<BForm @submit.prevent="resetLogin">
<BAlert v-if="!!message" class="mt-2" :variant="messageVariant" show>
{{ message }}
</BAlert>

<BCard header="Reset your password">
<BFormGroup label="Email Address">
<BFormInput v-model="email" type="email" />
</BFormGroup>

<BButton type="submit">Reset your password</BButton>
</BCard>
</BForm>
</div>
</div>
</template>
7 changes: 7 additions & 0 deletions client/src/entry/analysis/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import Analysis from "entry/analysis/modules/Analysis";
import CenterFrame from "entry/analysis/modules/CenterFrame";
import Home from "entry/analysis/modules/Home";
import Login from "entry/analysis/modules/Login";
import ResetPassword from "entry/analysis/modules/ResetPassword";
import WorkflowEditorModule from "entry/analysis/modules/WorkflowEditor";
import AdminRoutes from "entry/analysis/routes/admin-routes";
import LibraryRoutes from "entry/analysis/routes/library-routes";
Expand Down Expand Up @@ -121,6 +122,12 @@ export function getRouter(Galaxy) {
component: Login,
redirect: redirectLoggedIn(),
},
/** Login entry route */
{
path: "/login/reset_password",
component: ResetPassword,
redirect: redirectLoggedIn(),
},
/** Page editor */
{
path: "/pages/editor",
Expand Down

0 comments on commit 5bb2935

Please sign in to comment.