1313 v-on =" $listeners"
1414 >
1515 <div v-if =" confirmTypeRequired === 'relogin'" >
16- <el-row :gutter =" 24" style =" margin : 0 auto ; " >
16+ <el-row :gutter =" 24" style =" margin : 0 auto " >
1717 <el-col :md =" 24" :sm =" 24" >
18- <el-alert
19- :title =" $tc('ReLoginTitle')"
20- center
21- style =" margin-bottom : 20px ;"
22- type =" error"
23- />
18+ <el-alert :title =" $tc('ReLoginTitle')" center style =" margin-bottom : 20px " type =" error" />
2419 </el-col >
2520 </el-row >
26- <el-row :gutter =" 24" style =" margin : 0 auto ; " >
21+ <el-row :gutter =" 24" style =" margin : 0 auto " >
2722 <el-col :md =" 24" :sm =" 24" >
2823 <el-button class =" confirm-btn" size =" mini" type =" primary" @click =" logout" >
2924 {{ this.$t('ReLogin') }}
3227 </el-row >
3328 </div >
3429 <div v-else >
35- <el-row :gutter =" 24" style =" margin : 0 auto ; " >
30+ <el-row :gutter =" 24" style =" margin : 0 auto " >
3631 <el-col :md =" 24" :sm =" 24" :span =" 24" class =" add" >
3732 <el-select
3833 v-model =" subTypeSelected"
39- style =" width : 100% ; margin-bottom : 20px ; "
34+ style =" width : 100% ; margin-bottom : 20px "
4035 @change =" handleSubTypeChange"
4136 >
4237 <el-option
4944 </el-select >
5045 </el-col >
5146 </el-row >
52- <el-row v-if =" !noCodeMFA.includes(subTypeSelected)" :gutter =" 24" style =" margin : 0 auto ; " >
53- <el-col :md =" 24" :sm =" 24" style =" display : flex ; align-items : center ; " >
47+ <el-row v-if =" !noCodeMFA.includes(subTypeSelected)" :gutter =" 24" style =" margin : 0 auto " >
48+ <el-col :md =" 24" :sm =" 24" style =" display : flex ; align-items : center " >
5449 <el-input
5550 v-model =" secretValue"
5651 :placeholder =" inputPlaceholder"
5752 :show-password =" showPassword"
5853 @keyup.enter.native =" handleConfirm"
5954 />
60- <span v-if =" subTypeSelected === 'sms' || subTypeSelected === 'email'" style =" margin : -1px 0 0 20px ;" >
55+ <span
56+ v-if =" subTypeSelected === 'sms' || subTypeSelected === 'email'"
57+ style =" margin : -1px 0 0 20px "
58+ >
6159 <el-button
6260 :disabled =" smsBtnDisabled"
6361 size =" mini"
64- style =" line-height : 14px ; float : right ; "
62+ style =" line-height : 14px ; float : right "
6563 type =" primary"
6664 @click =" sendCode"
6765 >
7270 </el-row >
7371 <el-row >
7472 <el-col >
73+ <iframe v-if =" passkeyVisible" :src =" passkeyUrl" style =" display : none " />
7574 <iframe
76- v-if =" passkeyVisible"
77- :src =" passkeyUrl"
78- style =" display : none "
79- />
80- <iframe
81- v-if =" isFaceCaptureVisible && subTypeSelected ==='face' && faceCaptureUrl"
75+ v-if =" isFaceCaptureVisible && subTypeSelected === 'face' && faceCaptureUrl"
8276 :src =" faceCaptureUrl"
8377 allow =" camera"
8478 sandbox =" allow-scripts allow-same-origin"
85- style =" width : 100% ; height : 600px ;border : none ; "
79+ style =" width : 100% ; height : 600px ; border : none "
8680 />
8781 </el-col >
8882 </el-row >
89- <el-row :gutter =" 24" style =" margin : 20px auto 10px ; " >
83+ <el-row :gutter =" 24" style =" margin : 20px auto 10px " >
9084 <el-col :md =" 24" :sm =" 24" >
9185 <el-button
9286 v-if =" !noCodeMFA.includes(subTypeSelected)"
@@ -195,55 +189,65 @@ export default {
195189 this .$log .debug (' perform confirm action' )
196190 const confirmType = response .data ? .code
197191 const confirmUrl = ' /api/v1/authentication/confirm/'
198- this .$axios .get (confirmUrl, { params: { confirm_type: confirmType } }).then ((data ) => {
199- this .confirmTypeRequired = data .confirm_type
192+ this .$axios
193+ .get (confirmUrl, { params: { confirm_type: confirmType } })
194+ .then (data => {
195+ this .confirmTypeRequired = data .confirm_type
200196
201- if (this .confirmTypeRequired === ' relogin' ) {
202- this .$axios .post (confirmUrl, { ' confirm_type' : ' relogin' , ' secret_key' : ' x' }).then (() => {
203- this .callback ()
204- this .visible = false
205- }).catch (() => {
206- this .title = this .$t (' NeedReLogin' )
207- this .visible = true
208- })
209- return
210- }
211- this .subTypeChoices = data .content
212- const defaultSubType = this .subTypeChoices .filter (item => ! item .disabled )[0 ]
213- this .subTypeSelected = defaultSubType .name
214- this .inputPlaceholder = defaultSubType .placeholder
215- this .visible = true
216- }).catch ((err ) => {
217- const data = err .response ? .data
218- const msg = data? .error || data? .detail || data? .msg || this .$t (' GetConfirmTypeFailed' )
219- this .$message .error (msg)
220- this .cancel (err)
221- }).finally (() => {
222- this .processing = false
223- })
197+ if (this .confirmTypeRequired === ' relogin' ) {
198+ this .$axios
199+ .post (confirmUrl, { confirm_type: ' relogin' , secret_key: ' x' })
200+ .then (() => {
201+ this .callback ()
202+ this .visible = false
203+ })
204+ .catch (() => {
205+ this .title = this .$t (' NeedReLogin' )
206+ this .visible = true
207+ })
208+ return
209+ }
210+ this .subTypeChoices = data .content
211+ const defaultSubType = this .subTypeChoices .filter (item => ! item .disabled )[0 ]
212+ this .subTypeSelected = defaultSubType .name
213+ this .inputPlaceholder = defaultSubType .placeholder
214+ this .visible = true
215+ })
216+ .catch (err => {
217+ const data = err .response ? .data
218+ const msg = data? .error || data? .detail || data? .msg || this .$t (' GetConfirmTypeFailed' )
219+ this .$message .error (msg)
220+ this .cancel (err)
221+ })
222+ .finally (() => {
223+ this .processing = false
224+ })
224225 }, 500 ),
225226 logout () {
226227 window .location .href = ` ${ process .env .VUE_APP_LOGOUT_PATH } ?next=${ this .$route .fullPath } `
227228 },
228229 sendCode () {
229- this .$axios .post (` /api/v1/authentication/mfa/select/` , { type: this .subTypeSelected }).then (res => {
230- this .$message .success (this .$tc (' VerificationCodeSent' ))
231- let time = 60
232- this .smsBtnDisabled = true
230+ this .$axios
231+ .post (` /api/v1/authentication/mfa/select/` , { type: this .subTypeSelected })
232+ .then (res => {
233+ this .$message .success (this .$tc (' VerificationCodeSent' ))
234+ let time = 60
235+ this .smsBtnDisabled = true
233236
234- const interval = setInterval (() => {
235- time -= 1
236- this .smsBtnText = ` ${ this .$t (' Pending' )} : ${ time} `
237+ const interval = setInterval (() => {
238+ time -= 1
239+ this .smsBtnText = ` ${ this .$t (' Pending' )} : ${ time} `
237240
238- if (time <= 0 ) {
239- clearInterval (interval)
240- this .smsBtnText = this .$t (' SendVerificationCode' )
241- this .smsBtnDisabled = false
242- }
243- }, 1000 )
244- }).catch (() => {
245- this .$message .error (this .$tc (' FailedToSendVerificationCode' ))
246- })
241+ if (time <= 0 ) {
242+ clearInterval (interval)
243+ this .smsBtnText = this .$t (' SendVerificationCode' )
244+ this .smsBtnDisabled = false
245+ }
246+ }, 1000 )
247+ })
248+ .catch (() => {
249+ this .$message .error (this .$tc (' FailedToSendVerificationCode' ))
250+ })
247251 },
248252 handlePasskeyVerify () {
249253 this .passkeyVisible = true
@@ -267,23 +271,26 @@ export default {
267271 },
268272 startFaceCapture () {
269273 const url = ' /api/v1/authentication/face/context/'
270- this .$axios .post (url).then (data => {
271- const token = data[' token' ]
272- this .faceCaptureUrl = ' /facelive/capture?token=' + token
273- this .isFaceCaptureVisible = true
274+ this .$axios
275+ .post (url)
276+ .then (data => {
277+ const token = data[' token' ]
278+ this .faceCaptureUrl = ' /facelive/capture?token=' + token
279+ this .isFaceCaptureVisible = true
274280
275- const timer = setInterval (() => {
276- this .$axios .get (url + ` ?token=${ token} ` ).then (data => {
277- if (data[' is_finished' ]) {
278- clearInterval (timer)
279- this .isFaceCaptureVisible = false
280- this .handleConfirm ()
281- }
282- })
283- }, 1000 )
284- }).catch (() => {
285- this .$message .error (this .$tc (' FailedToStartFaceCapture' ))
286- })
281+ const timer = setInterval (() => {
282+ this .$axios .get (url + ` ?token=${ token} ` ).then (data => {
283+ if (data[' is_finished' ]) {
284+ clearInterval (timer)
285+ this .isFaceCaptureVisible = false
286+ this .handleConfirm ()
287+ }
288+ })
289+ }, 1000 )
290+ })
291+ .catch (() => {
292+ this .$message .error (this .$tc (' FailedToStartFaceCapture' ))
293+ })
287294 },
288295 handleFaceCapture () {
289296 this .startFaceCapture ()
@@ -306,16 +313,22 @@ export default {
306313 const data = {
307314 confirm_type: this .confirmTypeRequired ,
308315 mfa_type: this .confirmTypeRequired === ' mfa' ? this .subTypeSelected : ' ' ,
309- secret_key: this .confirmTypeRequired === ' password' ? encryptPassword (this .secretValue ) : this .secretValue
316+ secret_key:
317+ this .confirmTypeRequired === ' password'
318+ ? encryptPassword (this .secretValue )
319+ : this .secretValue
310320 }
311321
312- this .$axios .post (` /api/v1/authentication/confirm/` , data).then (() => {
313- this .onSuccess ()
314- }).catch ((err ) => {
315- this .$message .error (err .message || this .$tc (' ConfirmFailed' ))
316- this .faceCaptureUrl = null
317- this .isFaceCaptureVisible = false
318- })
322+ this .$axios
323+ .post (` /api/v1/authentication/confirm/` , data)
324+ .then (() => {
325+ this .onSuccess ()
326+ })
327+ .catch (err => {
328+ this .$message .error (err .message || this .$tc (' ConfirmFailed' ))
329+ this .faceCaptureUrl = null
330+ this .isFaceCaptureVisible = false
331+ })
319332 }
320333 }
321334}
0 commit comments