Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ui/public/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,5 +97,6 @@
"basicZoneEnabled": true,
"multipleServer": false,
"allowSettingTheme": true,
"displayProjectFieldOnLogin": false,
"docHelpMappings": {}
}
44 changes: 41 additions & 3 deletions ui/src/views/auth/Login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,18 @@
type="text"
:placeholder="$t('label.domain')"
v-model:value="form.domain"
>
<template #prefix>
<project-outlined />
</template>
</a-input>
</a-form-item>
<a-form-item ref="project" name="project" v-if="$config.displayProjectFieldOnLogin">
<a-input
size="large"
type="text"
:placeholder="$t('label.project')"
v-model:value="form.project"
>
<template #prefix>
<block-outlined />
Expand Down Expand Up @@ -230,7 +242,8 @@ export default {
loginType: 0
},
server: '',
forgotPasswordEnabled: false
forgotPasswordEnabled: false,
project: null
}
},
created () {
Expand All @@ -255,7 +268,8 @@ export default {
this.form = reactive({
server: (this.server.apiHost || '') + this.server.apiBase,
username: this.$route.query?.username || '',
domain: this.$route.query?.domain || ''
domain: this.$route.query?.domain || '',
project: null
})
this.rules = reactive({})
this.setRules()
Expand Down Expand Up @@ -447,7 +461,7 @@ export default {
})
})
},
loginSuccess (res) {
async loginSuccess (res) {
this.$notification.destroy()
this.$store.commit('SET_COUNT_NOTIFY', 0)
if (store.getters.twoFaEnabled === true && store.getters.twoFaProvider !== '' && store.getters.twoFaProvider !== undefined) {
Expand All @@ -456,9 +470,33 @@ export default {
this.$router.push({ path: '/setup2FA' }).catch(() => {})
} else {
this.$store.commit('SET_LOGIN_FLAG', true)
const values = toRaw(this.form)
if (values.project) {
await this.getProject(values.project)
this.$store.dispatch('ProjectView', this.project.id)
this.$store.dispatch('SetProject', this.project)
this.$store.dispatch('ToggleTheme', this.project.id === undefined ? 'light' : 'dark')
}
this.$router.push({ path: '/dashboard' }).catch(() => {})
}
},
getProject (projectName) {
return new Promise((resolve, reject) => {
api('listProjects', {
response: 'json',
domainId: this.selectedDomain,
details: 'min'
}).then((response) => {
const projects = response.listprojectsresponse.project
this.project = projects.filter(project => project.name === projectName)?.[0] || null
resolve(this.project)
}).catch((error) => {
this.$notifyError(error)
}).finally(() => {
this.loading = false
})
})
},
requestFailed (err) {
if (err && err.response && err.response.data && err.response.data.loginresponse) {
const error = err.response.data.loginresponse.errorcode + ': ' + err.response.data.loginresponse.errortext
Expand Down
Loading