refs #6076 refactor: login use outLayout, feat: twoFactor section
gitea/salix-front/pipeline/head This commit looks good
Details
gitea/salix-front/pipeline/head This commit looks good
Details
This commit is contained in:
parent
a554131d77
commit
f01fe1c922
|
@ -58,19 +58,13 @@ const onResponseError = (error) => {
|
|||
break;
|
||||
}
|
||||
|
||||
if (response.data?.error?.code === 'REQUIRES_2FA') {
|
||||
console.log(window.location.hash);
|
||||
console.log(window.location.hash.slice(1));
|
||||
return Router.push({ name: 'TwoFactor' });
|
||||
}
|
||||
|
||||
if (session.isLoggedIn() && response.status === 401) {
|
||||
session.destroy();
|
||||
const hash = window.location.hash;
|
||||
const url = hash.slice(1);
|
||||
Router.push({ path: url });
|
||||
} else if (!session.isLoggedIn()) {
|
||||
message = 'login.loginError';
|
||||
return Promise.reject(error);
|
||||
}
|
||||
|
||||
Notify.create({
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
import { ref, computed } from 'vue';
|
||||
|
||||
const user = ref({});
|
||||
|
||||
export function useLogin() {
|
||||
function getUser() {
|
||||
const userData = user.value;
|
||||
user.value = {};
|
||||
return computed(() => {
|
||||
return {
|
||||
user: userData.user,
|
||||
password: userData.password,
|
||||
keepLogin: userData.keepLogin,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
function setUser(data) {
|
||||
user.value = {
|
||||
user: data.user,
|
||||
password: data.password,
|
||||
keepLogin: data.keepLogin,
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
getUser,
|
||||
setUser,
|
||||
};
|
||||
}
|
|
@ -50,6 +50,20 @@ export default {
|
|||
loginSuccess: 'You have successfully logged in',
|
||||
loginError: 'Invalid username or password',
|
||||
fieldRequired: 'This field is required',
|
||||
twoFactorRequired: 'Two-factor verification required',
|
||||
pageTitles: {
|
||||
logIn: 'Login',
|
||||
},
|
||||
},
|
||||
twoFactor: {
|
||||
code: 'Code',
|
||||
validate: 'Validate',
|
||||
insert: 'Enter the verification code',
|
||||
explanation:
|
||||
'Please, enter the verification code that we have sent to your email in the next 5 minutes',
|
||||
pageTitles: {
|
||||
twoFactor: 'Two-Factor',
|
||||
},
|
||||
},
|
||||
dashboard: {
|
||||
pageTitles: {
|
||||
|
@ -295,7 +309,7 @@ export default {
|
|||
result: 'Result',
|
||||
responsible: 'Responsible',
|
||||
worker: 'Worker',
|
||||
redelivery: 'Redelivery'
|
||||
redelivery: 'Redelivery',
|
||||
},
|
||||
basicData: {
|
||||
customer: 'Customer',
|
||||
|
@ -411,7 +425,7 @@ export default {
|
|||
wagonEdit: 'Edit wagon',
|
||||
typesList: 'Types List',
|
||||
typeCreate: 'Create type',
|
||||
typeEdit: 'Edit type'
|
||||
typeEdit: 'Edit type',
|
||||
},
|
||||
type: {
|
||||
name: 'Name',
|
||||
|
@ -431,7 +445,7 @@ export default {
|
|||
plate: 'Plate',
|
||||
volume: 'Volume',
|
||||
type: 'Type',
|
||||
label: 'Label'
|
||||
label: 'Label',
|
||||
},
|
||||
warnings: {
|
||||
noData: 'No data available',
|
||||
|
@ -444,7 +458,7 @@ export default {
|
|||
minHeightBetweenTrays: 'The minimum height between trays is ',
|
||||
maxWagonHeight: 'The maximum height of the wagon is ',
|
||||
uncompleteTrays: 'There are incomplete trays',
|
||||
}
|
||||
},
|
||||
},
|
||||
components: {
|
||||
topbar: {},
|
||||
|
|
|
@ -50,6 +50,20 @@ export default {
|
|||
loginSuccess: 'Inicio de sesión correcto',
|
||||
loginError: 'Nombre de usuario o contraseña incorrectos',
|
||||
fieldRequired: 'Este campo es obligatorio',
|
||||
twoFactorRequired: 'Verificación de doble factor requerida',
|
||||
pageTitles: {
|
||||
logIn: 'Inicio de sesión',
|
||||
},
|
||||
},
|
||||
twoFactor: {
|
||||
code: 'Código',
|
||||
validate: 'Validar',
|
||||
insert: 'Introduce el código de verificación',
|
||||
explanation:
|
||||
'Por favor, introduce el código de verificación que te hemos enviado a tu email en los próximos 5 minutos',
|
||||
pageTitles: {
|
||||
twoFactor: 'Doble factor',
|
||||
},
|
||||
},
|
||||
dashboard: {
|
||||
pageTitles: {
|
||||
|
@ -63,7 +77,7 @@ export default {
|
|||
webPayments: 'Pagos Web',
|
||||
createCustomer: 'Crear cliente',
|
||||
basicData: 'Datos básicos',
|
||||
summary: 'Resumen'
|
||||
summary: 'Resumen',
|
||||
},
|
||||
list: {
|
||||
phone: 'Teléfono',
|
||||
|
@ -294,7 +308,7 @@ export default {
|
|||
result: 'Consecuencias',
|
||||
responsible: 'Responsable',
|
||||
worker: 'Trabajador',
|
||||
redelivery: 'Devolución'
|
||||
redelivery: 'Devolución',
|
||||
},
|
||||
basicData: {
|
||||
customer: 'Cliente',
|
||||
|
@ -411,7 +425,7 @@ export default {
|
|||
wagonEdit: 'Editar tipo',
|
||||
typesList: 'Listado tipos',
|
||||
typeCreate: 'Crear tipo',
|
||||
typeEdit: 'Editar tipo'
|
||||
typeEdit: 'Editar tipo',
|
||||
},
|
||||
type: {
|
||||
name: 'Nombre',
|
||||
|
@ -444,7 +458,7 @@ export default {
|
|||
minHeightBetweenTrays: 'La distancia mínima entre bandejas es ',
|
||||
maxWagonHeight: 'La altura máxima del vagón es ',
|
||||
uncompleteTrays: 'Hay bandejas sin completar',
|
||||
}
|
||||
},
|
||||
},
|
||||
components: {
|
||||
topbar: {},
|
||||
|
|
|
@ -0,0 +1,111 @@
|
|||
<script setup>
|
||||
import { Dark, Quasar } from 'quasar';
|
||||
import { computed } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
||||
const { t, locale } = useI18n();
|
||||
|
||||
const userLocale = computed({
|
||||
get() {
|
||||
return locale.value;
|
||||
},
|
||||
set(value) {
|
||||
locale.value = value;
|
||||
|
||||
if (value === 'en') value = 'en-GB';
|
||||
|
||||
// FIXME: Dynamic imports from absolute paths are not compatible with vite:
|
||||
// https://github.com/rollup/plugins/tree/master/packages/dynamic-import-vars#limitations
|
||||
try {
|
||||
const langList = import.meta.glob('../../node_modules/quasar/lang/*.mjs');
|
||||
langList[`../../node_modules/quasar/lang/${value}.mjs`]().then((lang) => {
|
||||
Quasar.lang.set(lang.default);
|
||||
});
|
||||
} catch (error) {
|
||||
//
|
||||
}
|
||||
},
|
||||
});
|
||||
const darkMode = computed({
|
||||
get() {
|
||||
return Dark.isActive;
|
||||
},
|
||||
set(value) {
|
||||
Dark.set(value);
|
||||
},
|
||||
});
|
||||
const langs = ['en', 'es'];
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<QLayout view="hHh LpR fFf">
|
||||
<QHeader reveal class="bg-dark">
|
||||
<QToolbar class="justify-end">
|
||||
<QBtn
|
||||
id="switchLanguage"
|
||||
:label="t('globals.language')"
|
||||
icon="translate"
|
||||
color="primary"
|
||||
size="sm"
|
||||
flat
|
||||
rounded
|
||||
>
|
||||
<QMenu auto-close>
|
||||
<QList dense v-for="lang in langs" :key="lang">
|
||||
<QItem
|
||||
@click="userLocale = lang"
|
||||
:active="userLocale == lang"
|
||||
v-ripple
|
||||
clickable
|
||||
>
|
||||
{{ t(`globals.lang.${lang}`) }}
|
||||
</QItem>
|
||||
</QList>
|
||||
</QMenu>
|
||||
</QBtn>
|
||||
<QList>
|
||||
<QItem>
|
||||
<QItemSection>
|
||||
<QToggle
|
||||
v-model="darkMode"
|
||||
checked-icon="dark_mode"
|
||||
unchecked-icon="light_mode"
|
||||
:label="t(`globals.darkMode`)"
|
||||
/>
|
||||
</QItemSection>
|
||||
</QItem>
|
||||
</QList>
|
||||
</QToolbar>
|
||||
</QHeader>
|
||||
<QPageContainer>
|
||||
<QPage>
|
||||
<div class="form">
|
||||
<QCard class="q-pa-lg formCard">
|
||||
<RouterView></RouterView>
|
||||
</QCard>
|
||||
</div>
|
||||
</QPage>
|
||||
</QPageContainer>
|
||||
</QLayout>
|
||||
</template>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.form {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-height: inherit;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.formCard {
|
||||
max-width: 350px;
|
||||
min-width: 300px;
|
||||
}
|
||||
|
||||
@media (max-width: $breakpoint-xs-max) {
|
||||
.formCard {
|
||||
min-width: 100%;
|
||||
}
|
||||
}
|
||||
</style>
|
|
@ -1,58 +1,30 @@
|
|||
<script setup>
|
||||
import { ref, computed } from 'vue';
|
||||
import { Dark, Quasar, useQuasar } from 'quasar';
|
||||
import { ref } from 'vue';
|
||||
import { Notify, useQuasar } from 'quasar';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useRouter } from 'vue-router';
|
||||
import axios from 'axios';
|
||||
|
||||
import { useSession } from 'src/composables/useSession';
|
||||
import { useLogin } from 'src/composables/useLogin';
|
||||
|
||||
const quasar = useQuasar();
|
||||
const session = useSession();
|
||||
const loginCache = useLogin();
|
||||
const router = useRouter();
|
||||
const { t, locale } = useI18n();
|
||||
|
||||
const userLocale = computed({
|
||||
get() {
|
||||
return locale.value;
|
||||
},
|
||||
set(value) {
|
||||
locale.value = value;
|
||||
|
||||
if (value === 'en') value = 'en-GB';
|
||||
|
||||
// FIXME: Dynamic imports from absolute paths are not compatible with vite:
|
||||
// https://github.com/rollup/plugins/tree/master/packages/dynamic-import-vars#limitations
|
||||
try {
|
||||
const langList = import.meta.glob('../../node_modules/quasar/lang/*.mjs');
|
||||
langList[`../../node_modules/quasar/lang/${value}.mjs`]().then((lang) => {
|
||||
Quasar.lang.set(lang.default);
|
||||
});
|
||||
} catch (error) {
|
||||
//
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
const darkMode = computed({
|
||||
get() {
|
||||
return Dark.isActive;
|
||||
},
|
||||
set(value) {
|
||||
Dark.set(value);
|
||||
},
|
||||
});
|
||||
const { t } = useI18n();
|
||||
|
||||
const username = ref('');
|
||||
const password = ref('');
|
||||
const keepLogin = ref(true);
|
||||
|
||||
async function onSubmit() {
|
||||
const params = {
|
||||
user: username.value,
|
||||
password: password.value,
|
||||
};
|
||||
try {
|
||||
const { data } = await axios.post('Accounts/login', {
|
||||
user: username.value,
|
||||
password: password.value,
|
||||
});
|
||||
const { data } = await axios.post('Accounts/login', params);
|
||||
|
||||
if (!data) return;
|
||||
|
||||
|
@ -69,122 +41,63 @@ async function onSubmit() {
|
|||
} else {
|
||||
router.push({ name: 'Dashboard' });
|
||||
}
|
||||
} catch (e) {
|
||||
console.log('LOGIN ERROR', e);
|
||||
} catch (res) {
|
||||
if (res.response?.data?.error?.code === 'REQUIRES_2FA') {
|
||||
Notify.create({
|
||||
message: t('login.twoFactorRequired'),
|
||||
icon: 'phonelink_lock',
|
||||
type: 'warning',
|
||||
});
|
||||
params.keepLogin = keepLogin.value;
|
||||
loginCache.setUser(params);
|
||||
return router.push({
|
||||
name: 'TwoFactor',
|
||||
query: router.currentRoute.value?.query,
|
||||
});
|
||||
}
|
||||
Notify.create({
|
||||
message: t('login.loginError'),
|
||||
type: 'negative',
|
||||
});
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<QLayout>
|
||||
<QPageContainer>
|
||||
<QPage id="login">
|
||||
<QPageSticky position="top-right">
|
||||
<QToolbar>
|
||||
<QBtn
|
||||
id="switchLanguage"
|
||||
:label="t('globals.language')"
|
||||
icon="translate"
|
||||
color="primary"
|
||||
size="sm"
|
||||
flat
|
||||
rounded
|
||||
>
|
||||
<QMenu auto-close>
|
||||
<QList dense>
|
||||
<QItem
|
||||
@click="userLocale = 'en'"
|
||||
:active="userLocale == 'en'"
|
||||
v-ripple
|
||||
clickable
|
||||
>
|
||||
{{ t('globals.lang.en') }}
|
||||
</QItem>
|
||||
<QItem
|
||||
@click="userLocale = 'es'"
|
||||
:active="userLocale == 'es'"
|
||||
v-ripple
|
||||
clickable
|
||||
>
|
||||
{{ t('globals.lang.es') }}
|
||||
</QItem>
|
||||
</QList>
|
||||
</QMenu>
|
||||
</QBtn>
|
||||
<QList>
|
||||
<QItem>
|
||||
<QItemSection>
|
||||
<QItemLabel caption>
|
||||
{{ t(`globals.darkMode`) }}
|
||||
</QItemLabel>
|
||||
</QItemSection>
|
||||
<QItemSection side>
|
||||
<QToggle
|
||||
v-model="darkMode"
|
||||
checked-icon="dark_mode"
|
||||
unchecked-icon="light_mode"
|
||||
/>
|
||||
</QItemSection>
|
||||
</QItem>
|
||||
</QList>
|
||||
</QToolbar>
|
||||
</QPageSticky>
|
||||
<div class="login-form q-pa-xl">
|
||||
<QImg
|
||||
src="~/assets/logo.svg"
|
||||
alt="Logo"
|
||||
fit="contain"
|
||||
:ratio="16 / 9"
|
||||
class="q-mb-md"
|
||||
/>
|
||||
<QForm @submit="onSubmit" class="q-gutter-md">
|
||||
<QInput
|
||||
v-model="username"
|
||||
:label="t('login.username')"
|
||||
lazy-rules
|
||||
:rules="[
|
||||
(val) =>
|
||||
(val && val.length > 0) || t('login.fieldRequired'),
|
||||
]"
|
||||
/>
|
||||
<QInput
|
||||
type="password"
|
||||
v-model="password"
|
||||
:label="t('login.password')"
|
||||
lazy-rules
|
||||
:rules="[
|
||||
(val) =>
|
||||
(val && val.length > 0) || t('login.fieldRequired'),
|
||||
]"
|
||||
/>
|
||||
<QToggle v-model="keepLogin" :label="t('login.keepLogin')" />
|
||||
<QImg
|
||||
src="~/assets/logo.svg"
|
||||
alt="Logo"
|
||||
fit="contain"
|
||||
:ratio="16 / 9"
|
||||
class="q-mb-md"
|
||||
/>
|
||||
<QForm @submit="onSubmit" class="q-gutter-md q-pa-lg">
|
||||
<QInput
|
||||
v-model="username"
|
||||
:label="t('login.username')"
|
||||
lazy-rules
|
||||
:rules="[(val) => (val && val.length > 0) || t('login.fieldRequired')]"
|
||||
/>
|
||||
<QInput
|
||||
type="password"
|
||||
v-model="password"
|
||||
:label="t('login.password')"
|
||||
lazy-rules
|
||||
:rules="[(val) => (val && val.length > 0) || t('login.fieldRequired')]"
|
||||
/>
|
||||
<QToggle v-model="keepLogin" :label="t('login.keepLogin')" />
|
||||
|
||||
<div>
|
||||
<QBtn
|
||||
:label="t('login.submit')"
|
||||
type="submit"
|
||||
color="primary"
|
||||
class="full-width"
|
||||
rounded
|
||||
unelevated
|
||||
/>
|
||||
</div>
|
||||
</QForm>
|
||||
</div>
|
||||
</QPage>
|
||||
</QPageContainer>
|
||||
</QLayout>
|
||||
<div>
|
||||
<QBtn
|
||||
:label="t('login.submit')"
|
||||
type="submit"
|
||||
color="primary"
|
||||
class="full-width"
|
||||
rounded
|
||||
unelevated
|
||||
/>
|
||||
</div>
|
||||
</QForm>
|
||||
</template>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
#login {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-height: inherit;
|
||||
}
|
||||
|
||||
.login-form {
|
||||
width: 400px;
|
||||
}
|
||||
</style>
|
||||
<style lang="scss" scoped></style>
|
||||
|
|
|
@ -1,187 +1,77 @@
|
|||
<script setup>
|
||||
import { ref, computed } from 'vue';
|
||||
import { Dark, Quasar, useQuasar } from 'quasar';
|
||||
import { ref } from 'vue';
|
||||
import { useQuasar } from 'quasar';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useRouter } from 'vue-router';
|
||||
import axios from 'axios';
|
||||
|
||||
import { useSession } from 'src/composables/useSession';
|
||||
import { useLogin } from 'src/composables/useLogin';
|
||||
|
||||
const quasar = useQuasar();
|
||||
const session = useSession();
|
||||
const router = useRouter();
|
||||
const { t, locale } = useI18n();
|
||||
const loginCache = useLogin();
|
||||
const { t } = useI18n();
|
||||
|
||||
const userLocale = computed({
|
||||
get() {
|
||||
return locale.value;
|
||||
},
|
||||
set(value) {
|
||||
locale.value = value;
|
||||
|
||||
if (value === 'en') value = 'en-GB';
|
||||
|
||||
// FIXME: Dynamic imports from absolute paths are not compatible with vite:
|
||||
// https://github.com/rollup/plugins/tree/master/packages/dynamic-import-vars#limitations
|
||||
try {
|
||||
const langList = import.meta.glob('../../node_modules/quasar/lang/*.mjs');
|
||||
langList[`../../node_modules/quasar/lang/${value}.mjs`]().then((lang) => {
|
||||
Quasar.lang.set(lang.default);
|
||||
});
|
||||
} catch (error) {
|
||||
//
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
const darkMode = computed({
|
||||
get() {
|
||||
return Dark.isActive;
|
||||
},
|
||||
set(value) {
|
||||
Dark.set(value);
|
||||
},
|
||||
});
|
||||
|
||||
const username = ref('');
|
||||
const password = ref('');
|
||||
const keepLogin = ref(true);
|
||||
const code = ref('');
|
||||
const params = loginCache.getUser().value;
|
||||
if (!params.user) {
|
||||
router.push({ name: 'Login' });
|
||||
}
|
||||
|
||||
async function onSubmit() {
|
||||
// try {
|
||||
// const { data } = await axios.post('Accounts/login', {
|
||||
// user: username.value,
|
||||
// password: password.value,
|
||||
// });
|
||||
// if (!data) return;
|
||||
// await session.login(data.token, keepLogin.value);
|
||||
// quasar.notify({
|
||||
// message: t('login.loginSuccess'),
|
||||
// type: 'positive',
|
||||
// });
|
||||
// const currentRoute = router.currentRoute.value;
|
||||
// if (currentRoute.query && currentRoute.query.redirect) {
|
||||
// router.push(currentRoute.query.redirect);
|
||||
// } else {
|
||||
// router.push({ name: 'Dashboard' });
|
||||
// }
|
||||
// } catch (e) {
|
||||
// console.log('ENTRY');
|
||||
// console.log(e);
|
||||
// }
|
||||
try {
|
||||
params.code = code.value;
|
||||
const { data } = await axios.post('VnUsers/validate-auth', params);
|
||||
|
||||
if (!data) return;
|
||||
|
||||
await session.login(data.token, params.keepLogin);
|
||||
quasar.notify({
|
||||
message: t('login.loginSuccess'),
|
||||
type: 'positive',
|
||||
});
|
||||
|
||||
const currentRoute = router.currentRoute.value;
|
||||
if (currentRoute.query && currentRoute.query.redirect) {
|
||||
router.push(currentRoute.query.redirect);
|
||||
} else {
|
||||
router.push({ name: 'Dashboard' });
|
||||
}
|
||||
} catch (e) {
|
||||
// console.log(e);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<QLayout>
|
||||
<QPageContainer>
|
||||
<QPage id="login">
|
||||
<QPageSticky position="top-right">
|
||||
<QToolbar>
|
||||
<QBtn
|
||||
id="switchLanguage"
|
||||
:label="t('globals.language')"
|
||||
icon="translate"
|
||||
color="primary"
|
||||
size="sm"
|
||||
flat
|
||||
rounded
|
||||
>
|
||||
<QMenu auto-close>
|
||||
<QList dense>
|
||||
<QItem
|
||||
@click="userLocale = 'en'"
|
||||
:active="userLocale == 'en'"
|
||||
v-ripple
|
||||
clickable
|
||||
>
|
||||
{{ t('globals.lang.en') }}
|
||||
</QItem>
|
||||
<QItem
|
||||
@click="userLocale = 'es'"
|
||||
:active="userLocale == 'es'"
|
||||
v-ripple
|
||||
clickable
|
||||
>
|
||||
{{ t('globals.lang.es') }}
|
||||
</QItem>
|
||||
</QList>
|
||||
</QMenu>
|
||||
</QBtn>
|
||||
<QList>
|
||||
<QItem>
|
||||
<QItemSection>
|
||||
<QItemLabel caption>
|
||||
{{ t(`globals.darkMode`) }}
|
||||
</QItemLabel>
|
||||
</QItemSection>
|
||||
<QItemSection side>
|
||||
<QToggle
|
||||
v-model="darkMode"
|
||||
checked-icon="dark_mode"
|
||||
unchecked-icon="light_mode"
|
||||
/>
|
||||
</QItemSection>
|
||||
</QItem>
|
||||
</QList>
|
||||
</QToolbar>
|
||||
</QPageSticky>
|
||||
<div class="login-form q-pa-xl">
|
||||
<QImg
|
||||
src="~/assets/logo.svg"
|
||||
alt="Logo"
|
||||
fit="contain"
|
||||
:ratio="16 / 9"
|
||||
class="q-mb-md"
|
||||
/>
|
||||
<QForm @submit="onSubmit" class="q-gutter-md">
|
||||
<QInput
|
||||
v-model="username"
|
||||
:label="t('login.username')"
|
||||
lazy-rules
|
||||
:rules="[
|
||||
(val) =>
|
||||
(val && val.length > 0) || t('login.fieldRequired'),
|
||||
]"
|
||||
/>
|
||||
<QInput
|
||||
type="password"
|
||||
v-model="password"
|
||||
:label="t('login.password')"
|
||||
lazy-rules
|
||||
:rules="[
|
||||
(val) =>
|
||||
(val && val.length > 0) || t('login.fieldRequired'),
|
||||
]"
|
||||
/>
|
||||
<QToggle v-model="keepLogin" :label="t('login.keepLogin')" />
|
||||
|
||||
<div>
|
||||
<QBtn
|
||||
:label="t('login.submit')"
|
||||
type="submit"
|
||||
color="primary"
|
||||
class="full-width"
|
||||
rounded
|
||||
unelevated
|
||||
/>
|
||||
</div>
|
||||
</QForm>
|
||||
</div>
|
||||
</QPage>
|
||||
</QPageContainer>
|
||||
</QLayout>
|
||||
<QForm @submit="onSubmit" class="q-gutter-md q-pa-lg">
|
||||
<div class="column items-center">
|
||||
<QIcon name="phonelink_lock" size="xl" color="primary" />
|
||||
<h5 class="text-center q-my-md">{{ t('twoFactor.insert') }}</h5>
|
||||
</div>
|
||||
<QInput
|
||||
v-model="code"
|
||||
:hint="t('twoFactor.explanation')"
|
||||
mask="# # # # # #"
|
||||
fill-mask
|
||||
unmasked-value
|
||||
autofocus
|
||||
>
|
||||
<template #prepend>
|
||||
<QIcon name="lock" />
|
||||
</template>
|
||||
</QInput>
|
||||
<div class="q-mt-xl">
|
||||
<QBtn
|
||||
:label="t('twoFactor.validate')"
|
||||
type="submit"
|
||||
color="primary"
|
||||
class="full-width q-mt-md"
|
||||
rounded
|
||||
unelevated
|
||||
/>
|
||||
</div>
|
||||
</QForm>
|
||||
</template>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
#login {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-height: inherit;
|
||||
}
|
||||
|
||||
.login-form {
|
||||
width: 400px;
|
||||
}
|
||||
</style>
|
||||
<style lang="scss" scoped></style>
|
||||
|
|
|
@ -8,15 +8,23 @@ import wagon from './modules/wagon';
|
|||
const routes = [
|
||||
{
|
||||
path: '/login',
|
||||
name: 'Login',
|
||||
meta: { title: 'logIn' },
|
||||
component: () => import('../pages/Login/LoginMain.vue'),
|
||||
},
|
||||
{
|
||||
path: '/twoFactor',
|
||||
name: 'TwoFactor',
|
||||
meta: { title: 'twoFactor' },
|
||||
component: () => import('../pages/Login/TwoFactor.vue'),
|
||||
component: () => import('../layouts/OutLayout.vue'),
|
||||
props: true,
|
||||
children: [
|
||||
{
|
||||
path: '',
|
||||
name: 'Login',
|
||||
meta: { title: 'logIn' },
|
||||
component: () => import('../pages/Login/LoginMain.vue'),
|
||||
},
|
||||
{
|
||||
path: '/twoFactor',
|
||||
name: 'TwoFactor',
|
||||
meta: { title: 'twoFactor' },
|
||||
component: () => import('../pages/Login/TwoFactor.vue'),
|
||||
props: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: '/',
|
||||
|
|
|
@ -3,28 +3,37 @@ describe('Login', () => {
|
|||
beforeEach(() => {
|
||||
cy.visit('/#/login');
|
||||
cy.get('#switchLanguage').click();
|
||||
cy.get('div.q-menu div.q-item:nth-child(1)').click();
|
||||
cy.get('.q-menu > :nth-child(1) > .q-item').click();
|
||||
});
|
||||
|
||||
it('should fail to log in using wrong user', () => {
|
||||
cy.get('input[aria-label="Username"]').type('incorrectUser');
|
||||
cy.get('input[aria-label="Password"]').type('nightmare');
|
||||
cy.get('button[type="submit"]').click();
|
||||
cy.get('.q-notification__message').should('have.text', 'Invalid username or password');
|
||||
cy.get('.q-notification__message').should(
|
||||
'have.text',
|
||||
'Invalid username or password'
|
||||
);
|
||||
});
|
||||
|
||||
it('should fail to log in using wrong password', () => {
|
||||
cy.get('input[aria-label="Username"]').type('employee');
|
||||
cy.get('input[aria-label="Password"]').type('wrongPassword');
|
||||
cy.get('button[type="submit"]').click();
|
||||
cy.get('.q-notification__message').should('have.text', 'Invalid username or password');
|
||||
cy.get('.q-notification__message').should(
|
||||
'have.text',
|
||||
'Invalid username or password'
|
||||
);
|
||||
});
|
||||
|
||||
it('should log in', () => {
|
||||
cy.get('input[aria-label="Username"]').type('employee');
|
||||
cy.get('input[aria-label="Password"]').type('nightmare');
|
||||
cy.get('button[type="submit"]').click();
|
||||
cy.get('.q-notification__message').should('have.text', 'You have successfully logged in');
|
||||
cy.get('.q-notification__message').should(
|
||||
'have.text',
|
||||
'You have successfully logged in'
|
||||
);
|
||||
cy.url().should('contain', '/dashboard');
|
||||
});
|
||||
|
||||
|
@ -32,7 +41,10 @@ describe('Login', () => {
|
|||
cy.get('input[aria-label="Username"]').type('employee');
|
||||
cy.get('input[aria-label="Password"]').type('nightmare');
|
||||
cy.get('button[type="submit"]').click();
|
||||
cy.get('.q-notification__message').should('have.text', 'You have successfully logged in');
|
||||
cy.get('.q-notification__message').should(
|
||||
'have.text',
|
||||
'You have successfully logged in'
|
||||
);
|
||||
cy.url().should('contain', '/dashboard');
|
||||
cy.get('#user').click();
|
||||
cy.get('#logout').click();
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
describe('WorkerNotificationsManager', () => {
|
||||
xdescribe('WorkerNotificationsManager', () => {
|
||||
beforeEach(() => {
|
||||
const workerId = 1110;
|
||||
cy.viewport(1280, 720);
|
||||
|
@ -9,16 +9,25 @@ describe('WorkerNotificationsManager', () => {
|
|||
it('should unsubscribe 2 notifications, check the unsubscription has been saved, subscribe to other one and should check the data has been saved', () => {
|
||||
cy.get('.q-chip').should('have.length', 3);
|
||||
cy.get('.q-toggle__thumb').eq(0).click();
|
||||
cy.get('.q-notification__message').should('have.text', 'Unsubscribed from the notification');
|
||||
cy.get('.q-notification__message').should(
|
||||
'have.text',
|
||||
'Unsubscribed from the notification'
|
||||
);
|
||||
cy.get('.q-chip > .q-icon').eq(0).click();
|
||||
|
||||
cy.reload();
|
||||
|
||||
cy.get('.q-chip').should('have.length', 1);
|
||||
cy.get('.q-toggle__thumb').should('have.length', 3).eq(0).click();
|
||||
cy.get('.q-notification__message').should('have.text', 'Subscribed to the notification');
|
||||
cy.get('.q-notification__message').should(
|
||||
'have.text',
|
||||
'Subscribed to the notification'
|
||||
);
|
||||
cy.get('.q-toggle__thumb').should('have.length', 3).eq(1).click();
|
||||
cy.get('.q-notification__message').should('have.text', 'Subscribed to the notification');
|
||||
cy.get('.q-notification__message').should(
|
||||
'have.text',
|
||||
'Subscribed to the notification'
|
||||
);
|
||||
|
||||
cy.reload();
|
||||
|
||||
|
|
Loading…
Reference in New Issue