97
97
</template >
98
98
</a-input >
99
99
</a-form-item >
100
+ <a-form-item ref =" project" name =" project" >
101
+ <a-input
102
+ size =" large"
103
+ type =" text"
104
+ :placeholder =" $t('label.project')"
105
+ v-model:value =" form.project"
106
+ >
107
+ <template #prefix >
108
+ <block-outlined />
109
+ </template >
110
+ </a-input >
111
+ </a-form-item >
100
112
</a-tab-pane >
101
113
<a-tab-pane key =" saml" :disabled =" idps.length === 0" >
102
114
<template #tab >
@@ -230,7 +242,8 @@ export default {
230
242
loginType: 0
231
243
},
232
244
server: ' ' ,
233
- forgotPasswordEnabled: false
245
+ forgotPasswordEnabled: false ,
246
+ project: null
234
247
}
235
248
},
236
249
created () {
@@ -255,7 +268,8 @@ export default {
255
268
this .form = reactive ({
256
269
server: (this .server .apiHost || ' ' ) + this .server .apiBase ,
257
270
username: this .$route .query ? .username || ' ' ,
258
- domain: this .$route .query ? .domain || ' '
271
+ domain: this .$route .query ? .domain || ' ' ,
272
+ project: null
259
273
})
260
274
this .rules = reactive ({})
261
275
this .setRules ()
@@ -447,7 +461,7 @@ export default {
447
461
})
448
462
})
449
463
},
450
- loginSuccess (res ) {
464
+ async loginSuccess (res ) {
451
465
this .$notification .destroy ()
452
466
this .$store .commit (' SET_COUNT_NOTIFY' , 0 )
453
467
if (store .getters .twoFaEnabled === true && store .getters .twoFaProvider !== ' ' && store .getters .twoFaProvider !== undefined ) {
@@ -456,9 +470,33 @@ export default {
456
470
this .$router .push ({ path: ' /setup2FA' }).catch (() => {})
457
471
} else {
458
472
this .$store .commit (' SET_LOGIN_FLAG' , true )
473
+ const values = toRaw (this .form )
474
+ if (values .project ) {
475
+ await this .getProject (values .project )
476
+ this .$store .dispatch (' ProjectView' , this .project .id )
477
+ this .$store .dispatch (' SetProject' , this .project )
478
+ this .$store .dispatch (' ToggleTheme' , this .project .id === undefined ? ' light' : ' dark' )
479
+ }
459
480
this .$router .push ({ path: ' /dashboard' }).catch (() => {})
460
481
}
461
482
},
483
+ getProject (projectName ) {
484
+ return new Promise ((resolve , reject ) => {
485
+ api (' listProjects' , {
486
+ response: ' json' ,
487
+ domainId: this .selectedDomain ,
488
+ details: ' min'
489
+ }).then ((response ) => {
490
+ const projects = response .listprojectsresponse .project
491
+ this .project = projects .filter (project => project .name === projectName)? .[0 ] || null
492
+ resolve (this .project )
493
+ }).catch ((error ) => {
494
+ this .$notifyError (error)
495
+ }).finally (() => {
496
+ this .loading = false
497
+ })
498
+ })
499
+ },
462
500
requestFailed (err ) {
463
501
if (err && err .response && err .response .data && err .response .data .loginresponse ) {
464
502
const error = err .response .data .loginresponse .errorcode + ' : ' + err .response .data .loginresponse .errortext
0 commit comments