Skip to content

Commit dd1e5f8

Browse files
committed
try to fix router issue on login/signup pages change
1 parent cfb28a6 commit dd1e5f8

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

adminforth/plugins/open-signup/custom/SignupPage.vue

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,11 @@
133133

134134

135135
<script setup lang="ts">
136-
import { onMounted, ref, computed, Ref, onBeforeMount } from 'vue';
136+
import { onMounted, ref, computed, Ref, onBeforeMount, nextTick } from 'vue';
137137
import { useCoreStore } from '@/stores/core';
138138
import { useUserStore } from '@/stores/user';
139139
import { callAdminForthApi, loadFile, applyRegexValidation } from '@/utils';
140-
import { useRoute, useRouter } from 'vue-router';
140+
import { onBeforeRouteUpdate, useRoute, useRouter } from 'vue-router';
141141
import { IconEyeSolid, IconEyeSlashSolid } from '@iconify-prerendered/vue-flowbite';
142142
import Button from '@/afcl/Button.vue';
143143
import Link from '@/afcl/Link.vue';
@@ -210,10 +210,6 @@ const validationError = computed(() => {
210210
211211
const error: Ref<string | null> = ref(null);
212212
213-
onMounted(async () => {
214-
emailInput.value?.focus();
215-
});
216-
217213
218214
const backgroundPosition = computed(() => {
219215
return coreStore.config?.loginBackgroundPosition || '1/2';
@@ -246,6 +242,7 @@ const passwordConstraints: Ref<{
246242
// }
247243
248244
onBeforeMount(() => {
245+
// console.log('⛔ SignUp Page. Before Mount: ', route)
249246
if (localStorage.getItem('isAuthorized') === 'true') {
250247
// if route has next param, redirect
251248
coreStore.fetchMenuAndResource();
@@ -258,15 +255,22 @@ onBeforeMount(() => {
258255
})
259256
260257
onMounted(async () => {
258+
emailInput.value?.focus();
259+
await coreStore.getPublicConfig();
261260
261+
await nextTick();
262+
await router.isReady();
262263
263-
await coreStore.getPublicConfig();
264264
// getPasswordConstraints
265+
console.log('⛔ SignUp Page. Before Mount: ', route.meta)
265266
passwordConstraints.value = await callAdminForthApi({
266267
path: `/plugin/${route.meta.pluginInstanceId}/password-constraints`,
267268
method: 'GET',
268269
});
269-
});
270+
})
271+
272+
// onMounted(async () => {
273+
// });
270274
271275
async function doSignup() {
272276
error.value = null;

adminforth/spa/src/views/LoginView.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ const backgroundPosition = computed(() => {
143143
onBeforeMount(() => {
144144
if (localStorage.getItem('isAuthorized') === 'true') {
145145
// if route has next param, redirect
146-
// coreStore.fetchMenuAndResource();
146+
coreStore.fetchMenuAndResource();
147147
if (route.query.next) {
148148
router.push(route.query.next.toString());
149149
} else {

0 commit comments

Comments
 (0)