log: ueky登录增加日志

develop
时启龙 2024-08-28 15:28:51 +08:00
parent 3e63dd2c7f
commit b158fb5f9c
2 changed files with 19 additions and 1 deletions

View File

@ -10,8 +10,11 @@ const actions = {
Login({ commit }, password) {
return new Promise((resolve, reject) => {
// 调用 ukey 获取 clientHello
console.log('执行 store.dispatch(ukey/Login)开始,传参为password:', password)
getClientHello(password).then(checkRes => {
console.log('调用 ukey getClientHello 方法,接口返回结果为:', checkRes)
if (checkRes.result !== 0) {
console.log('调用 ukey getClientHello 方法失败,接口返回结果为:', checkRes)
Cookies.remove('ngx_cookie')
ElMessage({ message: checkRes.message, type: 'error' })
resolve({
@ -19,23 +22,29 @@ const actions = {
})
}
const clientHello = checkRes.clientHello
console.log('clientHello:', clientHello)
Cookies.set('ngx_cookie', clientHello)
// 调用天融信单点登录获取 serverHello
getLoginRandom(clientHello)
.then(randomRes => {
console.log('调用 getLoginRandom 方法,接口返回结果为:', randomRes)
if (!randomRes.success) {
console.log('调用 getLoginRandom 方法失败,接口返回结果为:', randomRes)
resolve({
success: false
})
}
let serverHello = randomRes.data
const serverHello = randomRes.data
console.log('serverHello:', serverHello)
// 调用 ukey 获取 ClientAuth
getClientAuth(password, serverHello, clientHello)
.then(authRes => {
console.log('调用 ukey getClientAuth 方法,接口返回结果为:', authRes)
// 暂未用到
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const ClientAuth = authRes.clientAuth
if (authRes.result !== 0) {
console.log('调用 ukey getClientAuth 方法失败,接口返回结果为:', authRes)
ElMessage({ message: authRes.message, type: 'error' })
resolve({
success: false
@ -45,7 +54,9 @@ const actions = {
clientHello,
serverHello
}).then(tokenRes => {
console.log('调用 trxLogin 方法,接口返回结果为:', tokenRes)
if (!tokenRes.success) {
console.log('调用 trxLogin 方法失败,接口返回结果为:', tokenRes)
resolve({
success: false
})
@ -54,10 +65,12 @@ const actions = {
})
})
.catch(err => {
console.log('调用 ukey getClientAuth 方法 [catch] ,接口返回结果为:', err)
reject(err)
})
})
.catch(err => {
console.log('调用 getLoginRandom 方法 [catch] ,接口返回结果为:', err)
reject(err)
})
})

View File

@ -145,12 +145,17 @@ async function handleUkeyLogin() {
if (!loginFormRef.value) return
loginFormRef.value.validate(async valid => {
if (valid) {
console.log('UKEY: 密码校验通过')
console.log('store', store)
loading.value = true
const res = await store.dispatch('ukey/Login', loginForm.ukeyPassword).finally(() => (loading.value = false))
if (res && res.success) {
console.log('UKEY: 登录成功,云管融合登录接口返回', res)
// ukey
setUkeyPassword(loginForm.ukeyPassword)
goLogin(res.data)
} else {
console.log('UKEY: 登录失败,云管融合登录接口返回', res)
}
}
})