fix
This commit is contained in:
parent
c0a49cc1b6
commit
7e0031ba81
@ -1,5 +1,5 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { PerfectScrollbar } from 'vue3-perfect-scrollbar'
|
import { PerfectScrollbar } from 'vue3-perfect-scrollbar';
|
||||||
|
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const ability = useAbility()
|
const ability = useAbility()
|
||||||
@ -11,6 +11,7 @@ const logout = async () => {
|
|||||||
|
|
||||||
// Remove "accessToken" from cookie
|
// Remove "accessToken" from cookie
|
||||||
useCookie('accessToken').value = null
|
useCookie('accessToken').value = null
|
||||||
|
localStorage.removeItem('admin_access_token');
|
||||||
|
|
||||||
// Remove "userData" from cookie
|
// Remove "userData" from cookie
|
||||||
userData.value = null
|
userData.value = null
|
||||||
|
@ -1,14 +1,18 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import tree1 from '@images/misc/tree1.png'
|
import tree1 from '@images/misc/tree1.png';
|
||||||
import authV2LoginIllustrationBorderedDark from '@images/pages/auth-v2-login-illustration-bordered-dark.png'
|
import authV2LoginIllustrationBorderedDark from '@images/pages/auth-v2-login-illustration-bordered-dark.png';
|
||||||
import authV2LoginIllustrationBorderedLight from '@images/pages/auth-v2-login-illustration-bordered-light.png'
|
import authV2LoginIllustrationBorderedLight from '@images/pages/auth-v2-login-illustration-bordered-light.png';
|
||||||
import authV2LoginIllustrationDark from '@images/pages/auth-v2-login-illustration-dark.png'
|
import authV2LoginIllustrationDark from '@images/pages/auth-v2-login-illustration-dark.png';
|
||||||
import authV2LoginIllustrationLight from '@images/pages/auth-v2-login-illustration-light.png'
|
import authV2LoginIllustrationLight from '@images/pages/auth-v2-login-illustration-light.png';
|
||||||
import authV2MaskDark from '@images/pages/mask-v2-dark.png'
|
import authV2MaskDark from '@images/pages/mask-v2-dark.png';
|
||||||
import authV2MaskLight from '@images/pages/mask-v2-light.png'
|
import authV2MaskLight from '@images/pages/mask-v2-light.png';
|
||||||
import { VNodeRenderer } from '@layouts/components/VNodeRenderer'
|
import { VNodeRenderer } from '@layouts/components/VNodeRenderer';
|
||||||
import { themeConfig } from '@themeConfig'
|
import { themeConfig } from '@themeConfig';
|
||||||
import { VForm } from 'vuetify/components/VForm'
|
import axios from 'axios';
|
||||||
|
import { VForm } from 'vuetify/components/VForm';
|
||||||
|
import { useStore } from 'vuex';
|
||||||
|
import { ADMIN_LOGIN_API } from '../constants';
|
||||||
|
const store = useStore()
|
||||||
|
|
||||||
const authThemeImg = useGenerateImageVariant(authV2LoginIllustrationLight, authV2LoginIllustrationDark, authV2LoginIllustrationBorderedLight, authV2LoginIllustrationBorderedDark, true)
|
const authThemeImg = useGenerateImageVariant(authV2LoginIllustrationLight, authV2LoginIllustrationDark, authV2LoginIllustrationBorderedLight, authV2LoginIllustrationBorderedDark, true)
|
||||||
const authThemeMask = useGenerateImageVariant(authV2MaskLight, authV2MaskDark)
|
const authThemeMask = useGenerateImageVariant(authV2MaskLight, authV2MaskDark)
|
||||||
@ -33,37 +37,66 @@ const errors = ref({
|
|||||||
const refVForm = ref()
|
const refVForm = ref()
|
||||||
|
|
||||||
const credentials = ref({
|
const credentials = ref({
|
||||||
email: 'admin@demo.com',
|
email: '',
|
||||||
password: 'admin',
|
password: '',
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const isLoading = ref(false)
|
||||||
const rememberMe = ref(false)
|
const rememberMe = ref(false)
|
||||||
|
|
||||||
const login = async () => {
|
const login = async () => {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const res = await $api('/auth/login', {
|
store.dispatch('updateIsLoading', true)
|
||||||
method: 'POST',
|
isLoading.value = true
|
||||||
body: {
|
const response = await axios.post(ADMIN_LOGIN_API, {
|
||||||
email: credentials.value.email,
|
email: credentials.value.email,
|
||||||
password: credentials.value.password,
|
password: credentials.value.password,
|
||||||
},
|
});
|
||||||
onResponseError({ response }) {
|
|
||||||
errors.value = response._data.errors
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
const { accessToken, userData, userAbilityRules } = res
|
console.log("Response", response.data);
|
||||||
|
response.data.userData.avatar = "/images/avatars/avatar-1.png";
|
||||||
|
console.log("Response 2", response.data);
|
||||||
|
|
||||||
|
const { accessToken, userData, userAbilityRules } = response.data;
|
||||||
|
useCookie('userAbilityRules').value = userAbilityRules;
|
||||||
|
ability.update(userAbilityRules);
|
||||||
|
useCookie('userData').value = userData;
|
||||||
|
useCookie('accessToken').value = accessToken;
|
||||||
|
localStorage.setItem('admin_access_token',accessToken)
|
||||||
|
|
||||||
useCookie('userAbilityRules').value = userAbilityRules
|
|
||||||
ability.update(userAbilityRules)
|
|
||||||
useCookie('userData').value = userData
|
|
||||||
useCookie('accessToken').value = accessToken
|
|
||||||
await nextTick(() => {
|
await nextTick(() => {
|
||||||
router.replace(route.query.to ? String(route.query.to) : '/')
|
router.replace(route.query.to ? String(route.query.to) : '/');
|
||||||
})
|
});
|
||||||
} catch (err) {
|
} catch (error) {
|
||||||
console.error(err)
|
store.dispatch('updateIsLoading', false)
|
||||||
|
isLoading.value = false
|
||||||
|
console.error(error);
|
||||||
}
|
}
|
||||||
|
// try {
|
||||||
|
// const res = await $api('/auth/login', {
|
||||||
|
// method: 'POST',
|
||||||
|
// body: {
|
||||||
|
// email: credentials.value.email,
|
||||||
|
// password: credentials.value.password,
|
||||||
|
// },
|
||||||
|
// onResponseError({ response }) {
|
||||||
|
// errors.value = response._data.errors
|
||||||
|
// },
|
||||||
|
// })
|
||||||
|
|
||||||
|
// const { accessToken, userData, userAbilityRules } = res
|
||||||
|
|
||||||
|
// useCookie('userAbilityRules').value = userAbilityRules
|
||||||
|
// ability.update(userAbilityRules)
|
||||||
|
// useCookie('userData').value = userData
|
||||||
|
// useCookie('accessToken').value = accessToken
|
||||||
|
// await nextTick(() => {
|
||||||
|
// router.replace(route.query.to ? String(route.query.to) : '/')
|
||||||
|
// })
|
||||||
|
// } catch (err) {
|
||||||
|
// console.error(err)
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
const onSubmit = () => {
|
const onSubmit = () => {
|
||||||
@ -75,6 +108,13 @@ const onSubmit = () => {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
<VDialog v-model="isLoading" width="110" height="150" color="primary">
|
||||||
|
<VCardText class="" style="color: white !important;">
|
||||||
|
<div class="demo-space-x">
|
||||||
|
<VProgressCircular :size="40" color="primary" indeterminate />
|
||||||
|
</div>
|
||||||
|
</VCardText>
|
||||||
|
</VDialog>
|
||||||
<RouterLink to="/">
|
<RouterLink to="/">
|
||||||
<div class="auth-logo d-flex align-center gap-x-3">
|
<div class="auth-logo d-flex align-center gap-x-3">
|
||||||
<VNodeRenderer :nodes="themeConfig.app.logo" />
|
<VNodeRenderer :nodes="themeConfig.app.logo" />
|
||||||
@ -128,13 +168,13 @@ const onSubmit = () => {
|
|||||||
>
|
>
|
||||||
<VCardText>
|
<VCardText>
|
||||||
<h4 class="text-h4 mb-1">
|
<h4 class="text-h4 mb-1">
|
||||||
Welcome to <span class="text-capitalize">{{ themeConfig.app.title }}!</span> 👋🏻
|
Welcome to <span class="text-capitalize">{{ themeConfig.app.title }}!</span>
|
||||||
</h4>
|
</h4>
|
||||||
<p class="mb-0">
|
<p class="mb-0">
|
||||||
Please sign-in to your account and start the adventure
|
Please sign-in to your account and start the adventure
|
||||||
</p>
|
</p>
|
||||||
</VCardText>
|
</VCardText>
|
||||||
<VCardText>
|
<!-- <VCardText>
|
||||||
<VAlert
|
<VAlert
|
||||||
color="primary"
|
color="primary"
|
||||||
variant="tonal"
|
variant="tonal"
|
||||||
@ -146,7 +186,7 @@ const onSubmit = () => {
|
|||||||
Client Email: <strong>client@demo.com</strong> / Pass: <strong>client</strong>
|
Client Email: <strong>client@demo.com</strong> / Pass: <strong>client</strong>
|
||||||
</p>
|
</p>
|
||||||
</VAlert>
|
</VAlert>
|
||||||
</VCardText>
|
</VCardText> -->
|
||||||
|
|
||||||
<VCardText>
|
<VCardText>
|
||||||
<VForm
|
<VForm
|
||||||
|
Loading…
Reference in New Issue
Block a user