* Updated parameter forms
* Updated layout
* Updated login page
* Added 2FA authentication
This commit is contained in:
Antoine Nguyen
2021-05-29 09:57:35 +02:00
parent 4e7d660b44
commit ea98bed16b
29 changed files with 936 additions and 329 deletions
+1 -3
View File
@@ -1,9 +1,7 @@
<template>
<v-app v-if="!isAuthenticated">
<v-main>
<v-container fluid fill-height>
<router-view />
</v-container>
<router-view />
</v-main>
</v-app>
<v-app v-else>
+4
View File
@@ -5,5 +5,9 @@ const resource = 'account'
export default {
getMe () {
return repository.get(`/${resource}/me/`)
},
verifyTFACode (code) {
const payload = { code }
return repository.post(`${resource}/tfa/verify/`, payload)
}
}
+6 -2
View File
@@ -25,13 +25,17 @@ _axios.interceptors.response.use(
return response
},
function (error) {
if (error.response.status !== 401) {
if (error.response.status === 418) {
router.push({ name: 'TwoFA' })
return Promise.reject(error)
}
if (error.response.status !== 401 || router.currentRoute.path === '/login/') {
return Promise.reject(error)
}
const refreshToken = Cookies.get('refreshToken')
if (error.config.url.endsWith('/token/refresh/') || !refreshToken) {
store.dispatch('auth/logout')
router.push('/login/')
router.push({ name: 'Login' })
return Promise.reject(error)
}
return _axios.post('/token/refresh/', { refresh: refreshToken }).then(resp => {
@@ -20,6 +20,28 @@
<template v-slot:form.options="{ step }">
<domain-options-form :ref="`form_${step}`" :domain="domain" @createAdmin="updateCreateAdmin" />
</template>
<template v-slot:item.with_random_password="{ item }">
<template v-if="item.value">
<v-col cols="12" class="highligth white--text">
<v-row>
<v-col><span>{{ item.key }}</span></v-col>
<v-col class="text-right">{{ item.value|yesno }}</v-col>
</v-row>
<v-row>
<v-col class="text-right py-1">
{{ domain.domain_admin.password }}
<v-btn icon color="white" :title="'Copy to clipboard'|translate" @click="copyPassword">
<v-icon>mdi-clipboard-multiple-outline</v-icon>
</v-btn>
</v-col>
</v-row>
</v-col>
</template>
<template v-else>
<v-col><span class="grey--text">{{ item.key }}</span></v-col>
<v-col class="text-right">{{ item.value|yesno }}</v-col>
</template>
</template>
</creation-form>
</template>
@@ -80,6 +102,7 @@ export default {
if (this.createAdmin) {
result[3].items.push({ key: this.$gettext('Administrator name'), value: this.domain.domain_admin.username })
result[3].items.push({
name: 'with_random_password',
key: this.$gettext('Random password'),
value: this.domain.domain_admin.with_random_password,
type: 'yesno'
@@ -117,6 +140,11 @@ export default {
this.initDomain()
},
methods: {
copyPassword () {
navigator.clipboard.writeText(this.domain.domain_admin.password).then(() => {
bus.$emit('notification', { msg: this.$gettext('Password copied to clipboard') })
})
},
initDomain () {
this.domain = {
name: '',
@@ -154,6 +182,7 @@ export default {
delete data.domain_admin
}
this.$store.dispatch('domains/createDomain', data).then(resp => {
this.$router.push({ name: 'DomainDetail', params: { id: resp.data.pk } })
bus.$emit('notification', { msg: this.$gettext('Domain created') })
this.close()
})
@@ -161,3 +190,9 @@ export default {
}
}
</script>
<style lang="scss">
.highligth {
background-color: #515D78;
}
</style>
@@ -23,6 +23,7 @@
:label="'Random password' | translate"
:disabled="!createAdmin"
:hint="'Generate a random password for the administrator.' | translate"
@change="updatePassword"
persistent-hint
/>
<v-switch v-model="domain.domain_admin.with_mailbox"
@@ -41,6 +42,8 @@
</template>
<script>
import accounts from '@/api/accounts'
export default {
props: ['domain'],
data () {
@@ -49,6 +52,16 @@ export default {
}
},
methods: {
updatePassword (value) {
if (value) {
accounts.getRandomPassword().then(resp => {
this.$set(this.domain.domain_admin, 'password', resp.data.password)
})
} else {
delete this.domain.domain_admin.password
}
},
update (val) {
this.$emit('createAdmin', val)
}
@@ -21,22 +21,28 @@
<account-alias-form v-if="step >= 4" :ref="`form_${step}`" :account="account" />
</template>
<template v-slot:item.random_password="{ item }">
<v-col cols="12" class="highligth white--text">
<v-row>
<v-col><span>{{ item.key }}</span></v-col>
<v-col class="text-right" v-if="item.type === 'yesno'">
{{ item.value|yesno }}
</v-col>
</v-row>
<v-row>
<v-col class="text-right py-1">
{{ account.password }}
<v-btn icon color="white" :title="'Copy to clipboard'|translate" @click="copyPassword">
<v-icon>mdi-clipboard-multiple-outline</v-icon>
</v-btn>
</v-col>
</v-row>
</v-col>
<template v-if="item.value">
<v-col cols="12" class="highligth white--text">
<v-row>
<v-col><span>{{ item.key }}</span></v-col>
<v-col class="text-right" v-if="item.type === 'yesno'">
{{ item.value|yesno }}
</v-col>
</v-row>
<v-row>
<v-col class="text-right py-1">
{{ account.password }}
<v-btn icon color="white" :title="'Copy to clipboard'|translate" @click="copyPassword">
<v-icon>mdi-clipboard-multiple-outline</v-icon>
</v-btn>
</v-col>
</v-row>
</v-col>
</template>
<template v-else>
<v-col><span class="grey--text">{{ item.key }}</span></v-col>
<v-col class="text-right" v-if="item.type === 'yesno'">{{ item.value|yesno }}</v-col>
</template>
</template>
</creation-form>
</template>
+62 -58
View File
@@ -14,62 +14,64 @@
<v-list>
<template v-for="item in mainMenuItems">
<v-list-item
v-if="!item.children"
class="menu-item"
:to="item.to"
link
:key="item.title"
>
<v-list-item-icon v-if="item.icon">
<v-icon>{{ item.icon }}</v-icon>
</v-list-item-icon>
<template v-if="item.roles === undefined || item.roles.indexOf(authUser.role) !== -1">
<v-list-item
v-if="!item.children"
class="menu-item"
:to="item.to"
link
:key="item.title"
:exact="item.exact"
>
<v-list-item-icon v-if="item.icon">
<v-icon>{{ item.icon }}</v-icon>
</v-list-item-icon>
<v-list-item-content>
<v-list-item-title>{{ item.text }}</v-list-item-title>
</v-list-item-content>
</v-list-item>
<v-list-group v-else
color="white"
:key="item.text"
:prepend-icon="item.icon"
no-action>
<template v-slot:activator>
<v-list-item-title>{{ item.text }}</v-list-item-title>
</template>
<v-list-item-content>
<v-list-item-title>{{ item.text }}</v-list-item-title>
</v-list-item-content>
</v-list-item>
<v-list-group v-else
color="white"
:key="item.text"
:prepend-icon="item.icon"
no-action>
<template v-slot:activator>
<v-list-item-title>{{ item.text }}</v-list-item-title>
</template>
<template v-for="subitem in item.children">
<v-list-item v-if="!subitem.children"
:key="subitem.text"
:to="subitem.to"
link>
<v-list-item-content>
<v-list-item-title>{{ subitem.text }}</v-list-item-title>
</v-list-item-content>
</v-list-item>
<v-list-group v-else
:key="subitem.text"
:value="true"
no-action
sub-group>
<template v-slot:activator>
<v-list-item-title>{{ subitem.text }}</v-list-item-title>
</template>
<v-list-item v-for="subsubitem in subitem.children"
:key="subsubitem.text"
:to="subsubitem.to"
<template v-for="subitem in item.children">
<v-list-item v-if="!subitem.children"
:key="subitem.text"
:to="subitem.to"
link>
<v-list-item-title>{{ subsubitem.text }}</v-list-item-title>
<v-list-item-content>
<v-list-item-title>{{ subitem.text }}</v-list-item-title>
</v-list-item-content>
</v-list-item>
</v-list-group>
</template>
</v-list-group>
<v-list-group v-else
:key="subitem.text"
:value="true"
no-action
sub-group>
<template v-slot:activator>
<v-list-item-title>{{ subitem.text }}</v-list-item-title>
</template>
<v-list-item v-for="subsubitem in subitem.children"
:key="subsubitem.text"
:to="subsubitem.to"
link>
<v-list-item-title>{{ subsubitem.text }}</v-list-item-title>
</v-list-item>
</v-list-group>
</template>
</v-list-group>
</template>
</template>
</v-list>
<template v-slot:append>
<v-menu rounded="lg" offset-y top>
<template v-slot:activator="{ attrs, on }">
<div class="user-box justify-end white--text" v-bind="attrs" v-on="on">
<div class="d-flex user-box justify-center align-center white--text py-2" v-bind="attrs" v-on="on">
<v-avatar size="40" color="primary">
<span class="white--text headline">AN</span>
</v-avatar>
@@ -113,27 +115,33 @@ export default {
mainMenuItems: [
{
text: this.$gettext('Dashboard'),
icon: 'mdi-view-dashboard-outline'
to: { name: 'Dashboard' },
icon: 'mdi-view-dashboard-outline',
exact: true
},
{
text: this.$gettext('Domains'),
to: { name: 'DomainList' },
icon: 'mdi-domain'
icon: 'mdi-domain',
roles: ['DomainAdmins', 'Resellers', 'SuperAdmins']
},
{
text: this.$gettext('Identities'),
to: { name: 'Identities' },
icon: 'mdi-account'
icon: 'mdi-account',
roles: ['DomainAdmins', 'Resellers', 'SuperAdmins']
},
{
icon: 'mdi-history',
text: this.$gettext('Logs'),
to: { name: 'LogList' }
to: { name: 'AuditTrail' },
roles: ['SuperAdmins']
},
{
icon: 'mdi-cog',
text: this.$gettext('Parameters'),
children: []
children: [],
roles: ['SuperAdmins']
}
],
userMenuItems: [
@@ -158,7 +166,7 @@ export default {
methods: {
logout () {
this.$store.dispatch('auth/logout').then(() => {
this.$router.push('/login')
this.$router.push({ name: 'Login' })
})
}
}
@@ -178,10 +186,6 @@ export default {
}
.user-box {
box-sizing: border-box;
border: 1px solid #979797;
width: 100%;
background: rgba(0, 0, 0, 0.25);
padding: 5px;
}
</style>
@@ -0,0 +1,71 @@
<template>
<v-card class="mt-6">
<v-toolbar flat>
<v-spacer></v-spacer>
<v-text-field
v-model="search"
prepend-inner-icon="mdi-magnify"
:placeholder="'Search'|translate"
filled
outlined
dense
hide-details
/>
</v-toolbar>
<v-data-table
:headers="headers"
:items="logs"
:search="search"
class="elevation-1"
:options.sync="pagination"
>
<template v-slot:item.level="{ item }">
<v-chip :color="getLevelColor(item.level)" text-color="white" small>
{{ item.level }}
</v-chip>
</template>
</v-data-table>
</v-card>
</template>
<script>
import logs from '@/api/logs'
export default {
data () {
return {
logs: [],
headers: [
{ text: 'Date', value: 'date_created' },
{ text: 'Level', value: 'level' },
{ text: 'Logger', value: 'logger' },
{ text: 'Message', value: 'message' }
],
loading: true,
pagination: {
},
search: ''
}
},
created () {
logs.getAll().then(response => {
this.logs = response.data
this.loading = false
})
},
methods: {
getLevelColor (level) {
if (level === 'INFO') {
return 'primary'
}
if (level === 'WARNING') {
return 'orange'
}
if (level === 'CRITICAL') {
return 'red'
}
return ''
}
}
}
</script>
-72
View File
@@ -1,72 +0,0 @@
<template>
<v-layout>
<v-flex>
<v-toolbar flat color="white">
<v-toolbar-title>Logs</v-toolbar-title>
<v-divider class="mx-2" inset vertical></v-divider>
<v-spacer></v-spacer>
<v-text-field
v-model="search"
append-icon="mdi-magnify"
label="Search"
single-line
hide-details
></v-text-field>
</v-toolbar>
<v-data-table :headers="headers"
:items="logs"
:search="search"
class="elevation-1"
:options.sync="pagination"
>
<template slot="items" slot-scope="props">
<td>{{ props.item.date_created }}</td>
<td>
<v-chip v-if="props.item.level === 'INFO'"
color="primary" text-color="white" small>
{{ props.item.level }}
</v-chip>
<v-chip v-if="props.item.level === 'WARNING'"
color="orange" text-color="white" small>
{{ props.item.level }}
</v-chip>
<v-chip v-if="props.item.level === 'CRITICAL'"
color="red" text-color="white" small>
{{ props.item.level }}
</v-chip>
</td>
<td>{{ props.item.logger }}</td>
<td>{{ props.item.message }}</td>
</template>
</v-data-table>
</v-flex>
</v-layout>
</template>
<script>
import logs from '@/api/logs'
export default {
data () {
return {
logs: [],
headers: [
{ text: 'Date', value: 'date_created' },
{ text: 'Level', value: 'level' },
{ text: 'Logger', value: 'logger' },
{ text: 'Message', value: 'message' }
],
loading: true,
pagination: {
},
search: ''
}
},
created () {
logs.getAll().then(response => {
this.logs = response.data
this.loading = false
})
}
}
</script>
@@ -1,22 +1,28 @@
<template>
<v-layout>
<v-flex>
<v-tabs v-model="active">
<v-tab v-for="(element, index) in displayableElements"
:key="index"
>
{{ element.label }}
</v-tab>
<v-tabs-items v-model="active">
<v-tab-item
v-for="(element, index) in displayableElements"
:key="index"
>
<v-card>
<v-card-text>
<template v-for="(param, index) in displayableParams(element.parameters)">
<div class="my-4" :key="index">
<template v-if="param.widget === 'BooleanField'">
<div>
<v-toolbar flat>
<v-toolbar-title>{{ title }}</v-toolbar-title>
</v-toolbar>
<v-tabs v-model="active">
<v-tab v-for="(element, index) in displayableElements"
:key="index"
>
{{ element.label }}
</v-tab>
<v-tabs-items v-model="active">
<v-tab-item
v-for="(element, index) in displayableElements"
:key="index"
>
<v-card>
<v-card-text>
<template v-for="(param, index) in displayableParams(element.parameters)">
<div class="my-4" :key="index">
<template v-if="param.widget === 'SeparatorField'">
<h2>{{ param.label }}</h2>
</template>
<template v-else-if="param.widget === 'BooleanField'">
<v-switch
v-model="parameters[param.name]"
:label="param.label"
@@ -42,30 +48,30 @@
v-model="parameters[param.name]"
:error="formErrors[param.name] !== undefined"
:error-messages="formErrors[param.name]"
:type="param.widget === 'PasswordField' ? 'password' : 'text'"
v-else
dense
outlined
/>
</template>
</div>
</template>
</v-card-text>
</v-card>
</v-tab-item>
</v-tabs-items>
</v-tabs>
<v-btn fixed
dark
fab
bottom
right
color="green"
@click="save"
>
<v-icon>mdi-content-save</v-icon>
</v-btn>
</v-flex>
</v-layout>
</div>
</template>
</v-card-text>
</v-card>
</v-tab-item>
</v-tabs-items>
</v-tabs>
<v-btn fixed
dark
fab
bottom
right
color="green"
@click="save"
>
<v-icon>mdi-content-save</v-icon>
</v-btn>
</div>
</template>
<script>
@@ -85,6 +91,17 @@ export default {
displayableElements () {
const result = this.structure.filter(element => this.display(element))
return result
},
title () {
let result = this.$gettext('Parameters: ')
if (this.$route.params.app === 'core') {
result += this.$gettext('General')
} else if (this.$route.params.app === 'admin') {
result += this.$gettext('Administration')
} else if (this.$route.params.app === 'limits') {
result += this.$gettext('Limitations')
}
return result
}
},
created () {
@@ -108,11 +125,15 @@ export default {
if (element.display === '') {
return true
}
var [field, value] = element.display.split('=')
if (value === 'true' || value === 'false') {
value = Boolean(value)
}
return this.parameters[field] === value
let result = true
element.display.split('&').forEach(rule => {
var [field, value] = rule.split('=')
if (value === 'true' || value === 'false') {
value = Boolean(value)
}
result &= this.parameters[field] === value
})
return result
},
displayableParams (params) {
return params.filter(param => this.display(param))
@@ -127,3 +148,9 @@ export default {
}
}
</script>
<style scoped>
.v-toolbar {
background-color: #f7f8fa !important;
}
</style>
+41 -15
View File
@@ -4,11 +4,18 @@ import VueRouter from 'vue-router'
import store from '@/store'
import ParametersForm from '@/components/parameters/ParametersForm'
import LogList from '@/components/logs/LogList'
Vue.use(VueRouter)
const routes = [
{
path: '/',
name: 'Dashboard',
component: () => import(/* webpackChunkName: "dashboard" */ '../views/Dashboard.vue'),
meta: {
requiresAuth: true
}
},
{
path: '/login',
name: 'Login',
@@ -17,28 +24,36 @@ const routes = [
// which is lazy-loaded when the route is visited.
component: () => import(/* webpackChunkName: "about" */ '../views/Login.vue')
},
{
path: '/twofa',
name: 'TwoFA',
component: () => import('../views/TwoFA.vue')
},
{
path: '/domains',
name: 'DomainList',
component: () => import('../views/Domains.vue'),
component: () => import('../views/domains/Domains.vue'),
meta: {
requiresAuth: true
requiresAuth: true,
allowedRoles: ['DomainAdmins', 'Resellers', 'SuperAdmins']
}
},
{
path: '/domains/:id',
name: 'DomainDetail',
component: () => import('../views/Domain.vue'),
component: () => import('../views/domains/Domain.vue'),
meta: {
requiresAuth: true
requiresAuth: true,
allowedRoles: ['DomainAdmins', 'Resellers', 'SuperAdmins']
}
},
{
path: '/domains/:id/edit',
name: 'DomainEdit',
component: () => import('../views/DomainEdit.vue'),
component: () => import('../views/domains/DomainEdit.vue'),
meta: {
requiresAuth: true
requiresAuth: true,
allowedRoles: ['DomainAdmins', 'Resellers', 'SuperAdmins']
}
},
{
@@ -46,7 +61,8 @@ const routes = [
name: 'Identities',
component: () => import('../views/identities/Identities.vue'),
meta: {
requiresAuth: true
requiresAuth: true,
allowedRoles: ['DomainAdmins', 'Resellers', 'SuperAdmins']
}
},
{
@@ -54,7 +70,8 @@ const routes = [
name: 'AccountEdit',
component: () => import('../views/identities/AccountEdit.vue'),
meta: {
requiresAuth: true
requiresAuth: true,
allowedRoles: ['DomainAdmins', 'Resellers', 'SuperAdmins']
}
},
{
@@ -62,7 +79,8 @@ const routes = [
name: 'AliasEdit',
component: () => import('../views/identities/AliasEdit.vue'),
meta: {
requiresAuth: true
requiresAuth: true,
allowedRoles: ['DomainAdmins', 'Resellers', 'SuperAdmins']
}
},
{
@@ -70,15 +88,17 @@ const routes = [
name: 'ParametersEdit',
component: ParametersForm,
meta: {
requiresAuth: true
requiresAuth: true,
allowedRoles: ['SuperAdmins']
}
},
{
path: '/logs/',
name: 'LogList',
component: LogList,
name: 'AuditTrail',
component: () => import('../views/logs/AuditTrail.vue'),
meta: {
requiresAuth: true
requiresAuth: true,
allowedRoles: ['SuperAdmins']
}
}
]
@@ -93,8 +113,14 @@ router.beforeEach((to, from, next) => {
if (to.matched.some(record => record.meta.requiresAuth)) {
store.dispatch('auth/initialize').then(() => {
if (!store.getters['auth/isAuthenticated']) {
next('/login/')
next({ name: 'Login' })
} else {
if (to.meta.allowedRoles !== undefined) {
if (to.meta.allowedRoles.indexOf(store.getters['auth/authUser'].role) === -1) {
next({ name: 'Dashboard' })
return
}
}
next()
}
})
+7 -2
View File
@@ -40,8 +40,13 @@ const actions = {
})
},
createDomain ({ commit }, data) {
return domainApi.createDomain(data).then(response => {
commit(ADD_DOMAIN, { domain: response.data })
return new Promise((resolve, reject) => {
domainApi.createDomain(data).then(response => {
commit(ADD_DOMAIN, { domain: response.data })
resolve(response)
}).catch(error => {
reject(error)
})
})
},
updateDomain ({ commit }, data) {
+7
View File
@@ -0,0 +1,7 @@
<template>
<div>
<v-toolbar flat>
<v-toolbar-title><translate>Welcome to Modoboa</translate></v-toolbar-title>
</v-toolbar>
</div>
</template>
+64 -41
View File
@@ -1,58 +1,73 @@
<template>
<v-layout align-center justify-center>
<v-flex xs12 sm8 md4>
<v-card class="elevation-12" @keyup.enter="authenticate">
<v-toolbar dark color="primary">
<v-toolbar-title>Modoboa</v-toolbar-title>
</v-toolbar>
<v-card-text>
<v-text-field label="Utilisateur"
v-model="username"
:error="errors.username !== undefined"
:error-messages="errors.username"
prepend-icon="mdi-account"
>
</v-text-field>
<v-text-field label="Mot de passe"
type="password"
v-model="password"
:error="errors.password !== undefined"
:error-messages="errors.password"
prepend-icon="mdi-lock"
>
</v-text-field>
</v-card-text>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn color="primary" text @click="authenticate">
Connect
</v-btn>
</v-card-actions>
</v-card>
</v-flex>
</v-layout>
<v-row style="height: 100%; width: 80%; margin: 0 auto">
<v-col cols="0" sm="6" class="primary" style="height: 100%">
<v-img
src="../assets/Modoboa_RVB-BLANC-SANS.png"
max-width="300"
class="mt-10 ml-8"
/>
</v-col>
<v-col cols="12" sm="6" class="d-flex flex-column justify-center pa-10" @keyup.enter="authenticate">
<span class="primary--text mb-6 text-h4"><translate>Identification</translate></span>
<validation-observer ref="observer">
<validation-provider
v-slot="{ errors }"
rules="required"
>
<label class="m-label"><translate>Username</translate></label>
<v-text-field
v-model="username"
:error-messages="errors"
outlined
/>
</validation-provider>
<validation-provider
vid="password"
v-slot="{ errors }"
rules="required"
>
<label class="m-label"><translate>Password</translate></label>
<v-text-field
type="password"
v-model="password"
:error-messages="errors"
outlined
/>
</validation-provider>
<a href="" class="float-right primary--text"><translate>Forgot password?</translate></a>
<v-checkbox
v-model="rememberMe"
:label="'Remember me'|translate"
/>
</validation-observer>
<div class="d-flex justify-center">
<v-btn class="flex-grow-1" color="primary" large @click="authenticate">
<translate>Connect</translate>
</v-btn>
</div>
</v-col>
</v-row>
</template>
<script>
import Cookies from 'js-cookie'
import { mapGetters } from 'vuex'
import auth from '@/api/auth'
export default {
computed: {
...mapGetters({
endpoints: 'auth/endpoints'
})
},
data () {
return {
rememberMe: false,
username: '',
password: '',
errors: {}
}
},
methods: {
authenticate () {
async authenticate () {
const isValid = await this.$refs.observer.validate()
if (!isValid) {
return
}
const payload = {
username: this.username,
password: this.password
@@ -61,12 +76,20 @@ export default {
Cookies.set('token', resp.data.access, { sameSite: 'strict' })
Cookies.set('refreshToken', resp.data.refresh, { sameSite: 'strict' })
this.$store.dispatch('auth/initialize').then(() => {
this.$router.push('/')
this.$router.push({ name: 'Dashboard' })
})
}).catch(err => {
console.log(err)
if (err.response.status === 401) {
this.$refs.observer.setErrors({
password: this.$gettext('Invalid username and/or password')
})
}
})
}
}
}
</script>
<style>
</style>
+68
View File
@@ -0,0 +1,68 @@
<template>
<v-row style="height: 100%; width: 80%; margin: 0 auto">
<v-col cols="0" sm="6" class="primary" style="height: 100%">
<v-img
src="../assets/Modoboa_RVB-BLANC-SANS.png"
max-width="300"
class="mt-10 ml-8"
/>
</v-col>
<v-col cols="12" sm="6" class="d-flex flex-column justify-center pa-10" @keyup.enter="verifyCode">
<span class="primary--text mb-6 text-h4"><translate>Verification</translate></span>
<validation-observer ref="observer">
<validation-provider
v-slot="{ errors }"
vid="code"
rules="required"
>
<label class="m-label"><translate>Two-factor authentication code</translate></label>
<v-text-field
v-model="code"
prepend-icon="mdi-numeric"
:error-messages="errors"
:hint="'Enter the code from the two-factor app on your mobile device. If you have lost your device, you may enter one of your recovery codes.'|translate"
persistent-hint
dense
outlined
/>
</validation-provider>
</validation-observer>
<div class="d-flex justify-center mt-6">
<v-btn class="flex-grow-1" color="primary" large @click="verifyCode">
<translate>Verify code</translate>
</v-btn>
</div>
</v-col>
</v-row>
</template>
<script>
import Cookies from 'js-cookie'
import account from '@/api/account'
export default {
data () {
return {
code: null,
errors: {}
}
},
methods: {
async verifyCode () {
const isValid = await this.$refs.observer.validate()
if (!isValid) {
return
}
account.verifyTFACode(this.code).then(resp => {
Cookies.set('token', resp.data.access, { sameSite: 'strict' })
Cookies.set('refreshToken', resp.data.refresh, { sameSite: 'strict' })
this.$store.dispatch('auth/initialize').then(() => {
this.$router.push({ name: 'Dashboard' })
})
}).catch(error => {
this.$refs.observer.setErrors(error.response.data)
})
}
}
}
</script>
@@ -57,7 +57,7 @@ export default {
},
data () {
return {
domain: {},
domain: { pk: this.$route.params.id },
showEditForm: false,
showAdminList: false
}
@@ -79,3 +79,9 @@ export default {
}
}
</script>
<style scoped>
.v-toolbar {
background-color: #f7f8fa !important;
}
</style>
+24
View File
@@ -0,0 +1,24 @@
<template>
<div>
<v-toolbar flat>
<v-toolbar-title><translate>Audit trail</translate></v-toolbar-title>
</v-toolbar>
<audit-trail-list />
</div>
</template>
<script>
import AuditTrailList from '@/components/logs/AuditTrailList.vue'
export default {
components: {
AuditTrailList
}
}
</script>
<style scoped>
.v-toolbar {
background-color: #f7f8fa !important;
}
</style>