Skip to content

Commit a0ebc69

Browse files
authored
Merge pull request #1 from devforth/AdminForth/952
fix: enhance success message display and add stay logged in/logout fu…
2 parents 5579804 + ebf1e33 commit a0ebc69

File tree

2 files changed

+43
-5
lines changed

2 files changed

+43
-5
lines changed

custom/SetPassword.vue

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,16 @@
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')}}
@@ -146,6 +154,7 @@
146154
<script setup lang="ts">
147155
import { onMounted, ref, computed, Ref } from 'vue';
148156
import { useCoreStore } from '@/stores/core';
157+
import { useUserStore } from '@/stores/user';
149158
import { callAdminForthApi, loadFile, applyRegexValidation } from '@/utils';
150159
import { useRoute, useRouter } from 'vue-router';
151160
import { IconEyeSolid, IconEyeSlashSolid } from '@iconify-prerendered/vue-flowbite';
@@ -157,6 +166,7 @@ const loading = ref(true);
157166
const tokenValid = ref(false);
158167
const passwordSet = ref(false);
159168
169+
const userStore = useUserStore();
160170
const coreStore = useCoreStore();
161171
162172
const passwordConfirmationInput = ref(null);
@@ -170,6 +180,8 @@ const router = useRouter();
170180
const validationRunning = ref(false);
171181
const error = ref(null);
172182
183+
const isUserLoggedIn = localStorage.getItem('isAuthorized');
184+
173185
const 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>

custom/tsconfig.json

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,27 @@
44
"paths": {
55
"@/*": [
66
// "node_modules/adminforth/dist/spa/src/*"
7-
"../../../spa/src/*"
7+
"../../../adminforth/spa/src/*"
88
],
99
"*": [
1010
// "node_modules/adminforth/dist/spa/node_modules/*"
11-
"../../../spa/node_modules/*"
11+
"../../../adminforth/spa/node_modules/*"
1212
],
1313
"@@/*": [
1414
// "node_modules/adminforth/dist/spa/src/*"
1515
"."
1616
]
1717
}
18-
}
18+
},
19+
"include": [
20+
"./**/*.ts",
21+
"./**/*.tsx",
22+
"./**/*.vue",
23+
"../**/*.ts",
24+
"../**/*.tsx",
25+
"../**/*.vue",
26+
"../*.vue",
27+
"../*.ts",
28+
"../*.tsx"
29+
]
1930
}

0 commit comments

Comments
 (0)