diff --git a/public/site/controllers/site.php b/public/site/controllers/site.php index 471bc23..c5a36fb 100644 --- a/public/site/controllers/site.php +++ b/public/site/controllers/site.php @@ -1,6 +1,10 @@ user() && $page->uri() !== 'login') { + go('/login'); + } + $data = $page->toArray(); $data['template'] = (string) $page->template(); $data['newInspirations'] = (bool) page('inspirations')->children()->findBy('new', 'true'); diff --git a/src/router/router.js b/src/router/router.js index 41ba16e..a67252a 100644 --- a/src/router/router.js +++ b/src/router/router.js @@ -17,15 +17,13 @@ router.beforeEach(async (to, from, next) => { try { const res = await api.fetchData(to.path); - if (!res.user && to.path === '/login' && from.path === '/login') { - next(); - } else if (res.user && to.path === '/login') { - next('/'); - } else { - pageStore.page = res.page; - userStore.user = res.user; - next(); + if (to.path === '/login' && res.user) { + location.href = '/'; } + + pageStore.page = res.page; + userStore.user = res.user; + next(); } catch (error) { console.error(error); next(false); diff --git a/src/views/Account.vue b/src/views/Account.vue index d4d3e4d..515dab5 100644 --- a/src/views/Account.vue +++ b/src/views/Account.vue @@ -14,7 +14,7 @@ placeholder="mail@exemple.com" autocomplete="username" class="w-full rounded-md border border-grey-200 px-16 py-12" - :class="{ invalid: !isValidEmail }" + :class="{ invalid: emailRegex.test(email) }" required />

Email : {{ user.email }}

@@ -23,6 +23,17 @@ modifier +
  • + +
  • Client : {{ user.client.name }}

  • @@ -37,14 +48,12 @@ import { useUserStore } from '../stores/user'; import { ref, watch } from 'vue'; const { user } = storeToRefs(useUserStore()); + const email = ref(''); const isEditingEmail = ref(false); -const isValidEmail = ref(false); +const emailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/; -watch(email, (newEmail) => { - const regex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/; - isValidEmail.value = regex.test(newEmail); -}); +const password = ref(''); function updateEmail(event) { email.value = event.target.value;