edit: redirect to login with message on password change

This commit is contained in:
axolotle 2023-12-29 16:25:48 +01:00
parent 01affca1da
commit 3c2510edb9
5 changed files with 22 additions and 7 deletions

View file

@ -68,7 +68,7 @@ provide(formGroupExtras, {
</label> </label>
</slot> </slot>
<div> <div class="w-full">
<slot name="default" /> <slot name="default" />
<div <div

View file

@ -47,7 +47,7 @@ watch(
const onSubmit = handleSubmit(async (form) => { const onSubmit = handleSubmit(async (form) => {
loading.value = true loading.value = true
const { error, data } = await useApi('/update', { const { error } = await useApi('/update', {
method: 'PUT', method: 'PUT',
body: exclude(form, 'confirmpassword'), body: exclude(form, 'confirmpassword'),
}) })
@ -71,11 +71,13 @@ const onSubmit = handleSubmit(async (form) => {
icon: 'alert', icon: 'alert',
message, message,
} }
} else if (data.value) { } else {
// reset loggedin state and redirect to login // reset loggedin state and redirect to login
// FIXME toast ok message
useIsLoggedIn().value = false useIsLoggedIn().value = false
return navigateTo('/login') return navigateTo({
path: '/login',
query: { msg: 'password_changed_reconnect' },
})
} }
loading.value = false loading.value = false

View file

@ -39,6 +39,7 @@
"new_password": "New password", "new_password": "New password",
"no_apps": "There is no app to list here, either because no web app yet is installed on the server, or because you don't have access to any. Please check with the admins of the server for more infos!", "no_apps": "There is no app to list here, either because no web app yet is installed on the server, or because you don't have access to any. Please check with the admins of the server for more infos!",
"password": "Password", "password": "Password",
"password_changed_reconnect": "Your password has been changed, please reconnect.",
"possibly_invalid_password": "Password is possibly invalid", "possibly_invalid_password": "Password is possibly invalid",
"possibly_invalid_username": "Username is possibly invalid", "possibly_invalid_username": "Username is possibly invalid",
"primary_mail_adress": "Primary mail adress", "primary_mail_adress": "Primary mail adress",

View file

@ -21,7 +21,7 @@ export default defineNuxtRouteMiddleware(async (to, from) => {
const queryMsg = useQueryMsg() const queryMsg = useQueryMsg()
if (to.query.msg) { if (to.query.msg) {
queryMsg.value = from.query.msg as string queryMsg.value = to.query.msg as string
} else { } else {
queryMsg.value = null queryMsg.value = null
} }

View file

@ -16,6 +16,7 @@ useHead({
const isLoggedIn = useIsLoggedIn() const isLoggedIn = useIsLoggedIn()
const redirectUrl = useRedirectUrl() const redirectUrl = useRedirectUrl()
const queryMsg = useQueryMsg()
const { handleSubmit, setErrors } = useForm({ const { handleSubmit, setErrors } = useForm({
validationSchema: toTypedSchema( validationSchema: toTypedSchema(
@ -49,7 +50,7 @@ const login = handleSubmit(async (form) => {
</script> </script>
<template> <template>
<main class="w-50 m-auto max-w-[250px]"> <main class="w-50 m-auto max-w-[300px]">
<CustomLogo class="flex-none mx-auto w-1/2 mb-10" /> <CustomLogo class="flex-none mx-auto w-1/2 mb-10" />
<BaseAlert <BaseAlert
@ -61,6 +62,15 @@ const login = handleSubmit(async (form) => {
assertive assertive
/> />
<BaseAlert
v-if="queryMsg"
variant="info"
icon="login"
:message="t(queryMsg)"
class="mb-4"
assertive
/>
<form novalidate @submit="login"> <form novalidate @submit="login">
<FormField <FormField
name="username" name="username"
@ -74,6 +84,7 @@ const login = handleSubmit(async (form) => {
type="text" type="text"
:placeholder="t('username')" :placeholder="t('username')"
autocomplete="username" autocomplete="username"
class="w-full"
/> />
</FormField> </FormField>
@ -89,6 +100,7 @@ const login = handleSubmit(async (form) => {
type="password" type="password"
:placeholder="t('password')" :placeholder="t('password')"
autocomplete="current-password" autocomplete="current-password"
class="w-full"
/> />
</FormField> </FormField>