diff --git a/components/FormField.vue b/components/FormField.vue index 657c58d..3680c4a 100644 --- a/components/FormField.vue +++ b/components/FormField.vue @@ -68,7 +68,7 @@ provide(formGroupExtras, { -
+
{ loading.value = true - const { error, data } = await useApi('/update', { + const { error } = await useApi('/update', { method: 'PUT', body: exclude(form, 'confirmpassword'), }) @@ -71,11 +71,13 @@ const onSubmit = handleSubmit(async (form) => { icon: 'alert', message, } - } else if (data.value) { + } else { // reset loggedin state and redirect to login - // FIXME toast ok message useIsLoggedIn().value = false - return navigateTo('/login') + return navigateTo({ + path: '/login', + query: { msg: 'password_changed_reconnect' }, + }) } loading.value = false diff --git a/locales/en.json b/locales/en.json index 053232b..e304870 100644 --- a/locales/en.json +++ b/locales/en.json @@ -39,6 +39,7 @@ "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!", "password": "Password", + "password_changed_reconnect": "Your password has been changed, please reconnect.", "possibly_invalid_password": "Password is possibly invalid", "possibly_invalid_username": "Username is possibly invalid", "primary_mail_adress": "Primary mail adress", diff --git a/middleware/auth.global.ts b/middleware/auth.global.ts index b07e85c..bab7768 100644 --- a/middleware/auth.global.ts +++ b/middleware/auth.global.ts @@ -21,7 +21,7 @@ export default defineNuxtRouteMiddleware(async (to, from) => { const queryMsg = useQueryMsg() if (to.query.msg) { - queryMsg.value = from.query.msg as string + queryMsg.value = to.query.msg as string } else { queryMsg.value = null } diff --git a/pages/login.vue b/pages/login.vue index 57cabf1..f6f461b 100644 --- a/pages/login.vue +++ b/pages/login.vue @@ -16,6 +16,7 @@ useHead({ const isLoggedIn = useIsLoggedIn() const redirectUrl = useRedirectUrl() +const queryMsg = useQueryMsg() const { handleSubmit, setErrors } = useForm({ validationSchema: toTypedSchema( @@ -49,7 +50,7 @@ const login = handleSubmit(async (form) => {