3737 <!-- Modal body -->
3838 <div class =" p-4 md:p-5" >
3939 <!-- Success message -->
40- <div v-if =" passwordSet" class =" af-alert-success flex items-center justify-center p-4 mb-4 text-sm rounded-lg dark:text-white" role =" alert" >
41- <div class =" text-center" >
40+ <div v-if =" passwordSet" class =" af-alert-success flex items-center justify-center pt-4 text-sm rounded-lg dark:text-white" role =" alert" >
41+ <div v-if =" isUserLoggedIn === 'true'" class =" text-center w-full" >
42+ <p class =" text-start" >{{$t('Password set successfully to your new account')}}</p >
43+ <p class =" text-start font-bold pb-4" >{{$t('Stay logged in or log in to another account?')}}</p >
44+ <div class =" flex gap-4 w-full justify-between mt-4" >
45+ <Button class =" flex-1" @click =" stayLoggedIn" >{{ $t('Stay logged in') }}</Button >
46+ <Button class =" flex-1" @click =" logoutUser" >{{ $t('Log out ') }}</Button >
47+ </div >
48+ </div >
49+ <div v-else class =" text-center" >
4250 <p class =" mb-3" >{{$t('Password set successfully!')}}</p >
4351 <Link to =" /login" class =" inline-flex items-center px-4 py-2 text-sm font-medium text-white bg-blue-600 border border-transparent rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500" >
4452 {{$t('Go to Login')}}
146154<script setup lang="ts">
147155import { onMounted , ref , computed , Ref } from ' vue' ;
148156import { useCoreStore } from ' @/stores/core' ;
157+ import { useUserStore } from ' @/stores/user' ;
149158import { callAdminForthApi , loadFile , applyRegexValidation } from ' @/utils' ;
150159import { useRoute , useRouter } from ' vue-router' ;
151160import { IconEyeSolid , IconEyeSlashSolid } from ' @iconify-prerendered/vue-flowbite' ;
@@ -157,6 +166,7 @@ const loading = ref(true);
157166const tokenValid = ref (false );
158167const passwordSet = ref (false );
159168
169+ const userStore = useUserStore ();
160170const coreStore = useCoreStore ();
161171
162172const passwordConfirmationInput = ref (null );
@@ -170,6 +180,8 @@ const router = useRouter();
170180const validationRunning = ref (false );
171181const error = ref (null );
172182
183+ const isUserLoggedIn = localStorage .getItem (' isAuthorized' );
184+
173185const backgroundPosition = computed (() => {
174186 return coreStore .config ?.loginBackgroundPosition || ' 1/2' ;
175187});
@@ -259,4 +271,19 @@ async function setPassword() {
259271 passwordSet .value = true ;
260272 }
261273}
274+
275+ async function logoutUser() {
276+ userStore .unauthorize ();
277+ await userStore .logout ();
278+ router .push ({ name: ' login' })
279+ }
280+
281+ function stayLoggedIn() {
282+ coreStore .fetchMenuAndResource ();
283+ if (route .query .next ) {
284+ router .push (route .query .next .toString ());
285+ } else {
286+ router .push ({ name: ' home' });
287+ }
288+ }
262289 </script >
0 commit comments