Skip to content

Commit

Permalink
Merge branch 'v24.04'
Browse files Browse the repository at this point in the history
  • Loading branch information
dlohvinov committed May 21, 2024
2 parents 6fee7a0 + 5660adc commit 36b5ffd
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 63 deletions.
4 changes: 3 additions & 1 deletion src/components/auth/login/steps/the-login-first-step.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<template>
<wt-input
name="domain"
v-model.trim="domain"
:label="$t('auth.domain')"
:v="v$.domain"
autocomplete
/>

<div class="auth-form-actions">
Expand All @@ -23,9 +25,9 @@
<script setup>
import { useVuelidate } from '@vuelidate/core';
import { required } from '@vuelidate/validators';
import domainValidator from '@webitel/ui-sdk/src/validators/domainValidator';
import { computed, onMounted } from 'vue';
import { useStore } from 'vuex';
import domainValidator from '@webitel/ui-sdk/src/validators/domainValidator';
import { useNextOnEnter } from '../../../../composables/useNextOnEnter.js';
const props = defineProps({
Expand Down
31 changes: 12 additions & 19 deletions src/components/auth/login/steps/the-login-second-step.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,35 @@
<div>
<div class="auth-form-inner">
<wt-input
:value="domain"
:label="$t('auth.domain')"
:value="domain"
class="auth-form-inner--domain"
disabled
/>

<wt-input
name="username"
v-model.trim="username"
:label="$t('vocabulary.login')"
:v="v$.username"
autocomplete
/>

<wt-input
name="password"
v-model.trim="password"
:label="$t('auth.password')"
:v="v$.password"
type="password"
autocomplete
has-show-password
/>

<wt-checkbox
:selected="rememberCredentials"
:value="true"
:label="$t('auth.remember')"
@change="setProp({ prop: 'rememberCredentials', value: $event })"
type="password"
/>
</div>

<div class="auth-form-actions">
<wt-button
@click="emit('back')"
color="secondary"
@click="emit('back')"
>{{ $t('reusable.back') }}
</wt-button>

Expand All @@ -53,25 +50,21 @@ import { useVuelidate } from '@vuelidate/core';
import { required } from '@vuelidate/validators';
import { computed, onMounted } from 'vue';
import { useStore } from 'vuex';
import LoginProviders from '../providers/the-login-providers.vue';
import { useNextOnEnter } from '../../../../composables/useNextOnEnter.js';
import LoginProviders from '../providers/the-login-providers.vue';
const emit = defineEmits(['back', 'next']);
const store = useStore();
1
1;
const domain = computed(() => store.state.auth.domain);
const username = computed({
get: () => store.state.auth.username,
set: (value) => setProp({ prop: 'username', value })
set: (value) => setProp({ prop: 'username', value }),
});
const password = computed({
get: () => store.state.auth.password,
set: (value) => setProp({ prop: 'password', value })
});
const rememberCredentials = computed({
get: () => store.state.auth.rememberCredentials,
set: (value) => setProp({ prop: 'rememberCredentials', value })
set: (value) => setProp({ prop: 'password', value }),
});
const v$ = useVuelidate(
Expand All @@ -87,7 +80,7 @@ const v$ = useVuelidate(
{ $autoDirty: true },
);
onMounted(() => { v$.value.$touch() });
onMounted(() => { v$.value.$touch(); });
useNextOnEnter(() => !v$.value.$invalid && emit('next'));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<template>
<div>
<wt-input
name="domain"
v-model.trim="domain"
:label="$t('auth.domain')"
:v="v$.domain"
autocomplete
/>

<div class="auth-form-actions">
Expand Down
14 changes: 3 additions & 11 deletions src/components/auth/register/steps/the-register-second-step.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@
<div>
<div class="auth-form-inner">
<wt-input
name="username"
v-model.trim="username"
:label="$t('vocabulary.login')"
:v="v$.username"
type="username"
/>

<wt-input
name="password"
v-model.trim="password"
:label="$t('auth.password')"
:v="v$.password"
Expand All @@ -22,13 +25,6 @@
type="password"
@keyup.enter="emit('next')"
/>

<wt-checkbox
:selected="rememberCredentials"
:value="true"
:label="$t('auth.remember')"
@change="setProp({ prop: 'rememberCredentials', value: $event })"
/>
</div>

<div class="auth-form-actions">
Expand Down Expand Up @@ -70,10 +66,6 @@ const confirmPassword = computed({
get: () => store.state.auth.confirmPassword,
set: (value) => setProp({ prop: 'confirmPassword', value })
});
const rememberCredentials = computed({
get: () => store.state.auth.rememberCredentials,
set: (value) => setProp({ prop: 'rememberCredentials', value })
});
const v$ = useVuelidate(
computed(() => ({
Expand Down
1 change: 0 additions & 1 deletion src/locale/en/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export default {
registerSubmit: 'Register',
signIn: 'Sign in',
login: 'Log in',
remember: 'Remember',
code: 'Code',
enterAuthenticationCode: 'Enter your two-factor authentication code',
carousel: {
Expand Down
1 change: 0 additions & 1 deletion src/locale/ru/ru.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export default {
registerSubmit: 'Создать',
signIn: 'Войти',
login: 'Войти',
remember: 'Запомнить',
code: 'Код',
enterAuthenticationCode: 'Введите ваш код двухфакторной аутентификации',
},
Expand Down
1 change: 0 additions & 1 deletion src/locale/ua/ua.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export default {
registerSubmit: 'Створити',
signIn: 'Увійти',
login: 'Увійти',
remember: 'Запам\'ятати',
code: 'Код',
enterAuthenticationCode: 'Введіть ваш код двофакторної автентифікації',
},
Expand Down
19 changes: 0 additions & 19 deletions src/store/modules/auth/__tests__/auth.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,32 +103,13 @@ describe('auth store', () => {
it('CACHE_USER_DATA caches domain by default', async () => {
const domain = 'domain';
context.state.domain = domain;
context.state.rememberCredentials = false;

const mock = vi.spyOn(localStorage, 'setItem').mockImplementationOnce(vi.fn());

await auth.actions.CACHE_USER_DATA(context);
expect(mock).toHaveBeenCalledWith('auth/domain', domain);
});

it('CACHE_USER_DATA caches username + password + remCreds, if remCreds is true', async () => {
const username = 'vi1';
const password = 'vi2';

context.state = {
username,
password,
rememberCredentials: true,
};

const mock = vi.spyOn(localStorage, 'setItem').mockImplementationOnce(vi.fn());

await auth.actions.CACHE_USER_DATA(context);
expect(mock).toHaveBeenCalledWith('auth/username', username);
expect(mock).toHaveBeenCalledWith('auth/password', password);
expect(mock).toHaveBeenCalledWith('auth/rememberCredentials', 'true');
});

it('CHECK_DOMAIN action calls AuthAPI.checkDomainExistence with domain from state', async () => {
const domain = 'domain';
context.state.domain = domain;
Expand Down
10 changes: 0 additions & 10 deletions src/store/modules/auth/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ const defaultState = () => ({

const state = {
...defaultState(),
rememberCredentials: localStorage.getItem('auth/rememberCredentials') === 'true',
loginProviders: {},
enabledTfa: false,
totp: '',
Expand Down Expand Up @@ -117,15 +116,6 @@ const actions = {

CACHE_USER_DATA: (context) => {
if (context.state.domain) localStorage.setItem('auth/domain', context.state.domain);
if (context.state.rememberCredentials) {
if (context.state.username) localStorage.setItem('auth/username', context.state.username);
if (context.state.password) localStorage.setItem('auth/password', context.state.password);
localStorage.setItem('auth/rememberCredentials', 'true');
} else {
localStorage.removeItem('auth/username');
localStorage.removeItem('auth/password');
localStorage.removeItem('auth/rememberCredentials');
}
},

CHECK_DOMAIN: (context, domain = context.state.domain) => {
Expand Down

0 comments on commit 36b5ffd

Please sign in to comment.