You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ha...@apache.org on 2022/11/03 09:10:18 UTC
[cloudstack] 03/03: partial changes on login page
This is an automated email from the ASF dual-hosted git repository.
harikrishna pushed a commit to branch 2FA
in repository https://gitbox.apache.org/repos/asf/cloudstack.git
commit c820e685566026c13a783edb1ecc40d9d633c39e
Author: Harikrishna Patnala <ha...@gmail.com>
AuthorDate: Thu Nov 3 14:39:45 2022 +0530
partial changes on login page
---
ui/src/components/page/GlobalLayout.vue | 10 +++-------
ui/src/config/router.js | 19 ++++++++++---------
ui/src/store/modules/user.js | 1 +
ui/src/views/auth/Login.vue | 19 +++++++++----------
ui/src/views/dashboard/Dashboard.vue | 5 +----
ui/src/views/dashboard/TwoFa.vue | 6 +++++-
6 files changed, 29 insertions(+), 31 deletions(-)
diff --git a/ui/src/components/page/GlobalLayout.vue b/ui/src/components/page/GlobalLayout.vue
index d55f19e49eb..3f8779d6062 100644
--- a/ui/src/components/page/GlobalLayout.vue
+++ b/ui/src/components/page/GlobalLayout.vue
@@ -17,8 +17,7 @@
<template>
<a-layout class="layout" :class="[device]">
-
- <a-affix style="z-index: 200" v-if="$store.getters.loginFlag">
+ <a-affix style="z-index: 200">
<template v-if="isSideMenu()">
<a-drawer
v-if="isMobile()"
@@ -80,7 +79,7 @@
<a-layout :class="[layoutMode, `content-width-${contentWidth}`]" :style="{ paddingLeft: contentPaddingLeft, minHeight: '100vh' }">
<!-- layout header -->
- <a-affix style="z-index: 100" v-if="$store.getters.loginFlag">
+ <a-affix style="z-index: 100">
<global-header
:mode="layoutMode"
:menus="menus"
@@ -158,10 +157,7 @@ export default {
return '0'
}
if (this.sidebarOpened) {
- if (this.$store.getters.loginFlag) {
- return '256px'
- }
- return '0'
+ return '256px'
}
return '80px'
}
diff --git a/ui/src/config/router.js b/ui/src/config/router.js
index 38fb05a34ec..e45977c4f64 100644
--- a/ui/src/config/router.js
+++ b/ui/src/config/router.js
@@ -223,15 +223,6 @@ export function asyncRouterMap () {
},
component: () => import('@/views/dashboard/Dashboard')
},
- // {
- // path: '/2FA',
- // name: 'TwoFA',
- // meta: {
- // title: 'label.2fa',
- // hidden: true
- // },
- // component: () => import('@/views/dashboard/2FA')
- // },
generateRouterMap(compute),
generateRouterMap(storage),
@@ -250,6 +241,16 @@ export function asyncRouterMap () {
generateRouterMap(quota),
generateRouterMap(cloudian),
+ {
+ path: '/2FA',
+ name: 'TwoFa',
+ meta: {
+ title: 'label.2fa',
+ hidden: true
+ },
+ component: () => import('@/views/dashboard/TwoFa')
+ },
+
{
path: '/exception',
name: 'exception',
diff --git a/ui/src/store/modules/user.js b/ui/src/store/modules/user.js
index 262ac7676aa..5a83e9bb1da 100644
--- a/ui/src/store/modules/user.js
+++ b/ui/src/store/modules/user.js
@@ -181,6 +181,7 @@ const user = {
commit('SET_DOMAIN_STORE', {})
commit('SET_LOGOUT_FLAG', false)
// TODO: get value from session and set - currently hard-coding it
+ // commit('SET_2FA_ENABLED', (result.is2faenabled === 'true'))
commit('SET_2FA_ENABLED', true)
commit('SET_LOGIN_FLAG', false)
notification.destroy()
diff --git a/ui/src/views/auth/Login.vue b/ui/src/views/auth/Login.vue
index e9f34499d07..983ad03cd10 100644
--- a/ui/src/views/auth/Login.vue
+++ b/ui/src/views/auth/Login.vue
@@ -278,15 +278,7 @@ export default {
loginParams.domain = '/'
}
this.Login(loginParams)
- .then((res) => {
- if (store.getters.twoFaEnabled) {
- this.$notification.destroy()
- this.$store.commit('SET_COUNT_NOTIFY', 0)
- this.$router.push({ path: '/dashboard' }).catch(() => {})
- } else {
- this.loginSuccess(res)
- }
- })
+ .then((res) => this.loginSuccess(res))
.catch(err => {
this.requestFailed(err)
this.state.loginBtn = false
@@ -307,7 +299,14 @@ export default {
this.$notification.destroy()
this.$store.commit('SET_COUNT_NOTIFY', 0)
this.$store.commit('SET_LOGIN_FLAG', true)
- this.$router.push({ path: '/dashboard' }).catch(() => {})
+ console.log(store.getters.twoFaEnabled)
+ if (store.getters.twoFaEnabled === true) {
+ console.log('hari1')
+ this.$router.push({ path: '/2FA' }).catch(() => {})
+ } else {
+ console.log('hari2')
+ this.$router.push({ path: '/dashboard' }).catch(() => {})
+ }
},
requestFailed (err) {
if (err && err.response && err.response.data && err.response.data.loginresponse) {
diff --git a/ui/src/views/dashboard/Dashboard.vue b/ui/src/views/dashboard/Dashboard.vue
index 325b3c1748e..e07b7735bdd 100644
--- a/ui/src/views/dashboard/Dashboard.vue
+++ b/ui/src/views/dashboard/Dashboard.vue
@@ -17,10 +17,7 @@
<template>
<div class="page-header-index-wide">
- <div v-if="!$store.getters.loginFlag">
- <two-fa />
- </div>
- <div v-else-if="showOnboarding">
+ <div v-if="showOnboarding">
<onboarding-dashboard />
</div>
<div v-else-if="$store.getters.userInfo.roletype === 'Admin' && !project">
diff --git a/ui/src/views/dashboard/TwoFa.vue b/ui/src/views/dashboard/TwoFa.vue
index eb95d638426..0f9e6017642 100644
--- a/ui/src/views/dashboard/TwoFa.vue
+++ b/ui/src/views/dashboard/TwoFa.vue
@@ -64,8 +64,8 @@ import { ref, reactive, toRaw } from 'vue'
export default {
name: 'TwoFa',
data () {
- console.log('here')
return {
+ twoFAresponse: false
}
},
created () {
@@ -84,6 +84,10 @@ export default {
const values = toRaw(this.form)
console.log(values.secretkey)
api('validateUserTwoFactorAuthenticationCode', { '2facode': values.secretkey }).then(response => {
+ this.twoFAresponse = true
+ if (this.twoFAresponse) {
+ this.$router.push({ path: '/dashboard' }).catch(() => {})
+ }
console.log(response)
}).catch(error => {
this.$notification.error({