开发


// src/views/login/login.vue
async PKILogin() {
    try {
        if (!this.loginForm.agreement) {
            this.noticePrivacyPolicy()
            return
        }
        this.loading = true
        let original = await this.getOriginal()
        if (original) {
            // VCTK初始化参数,数据可从网关系统:认证管理->Key类型管理中导出
            // 调用网关工具脚本中的detachSignStr方法进行签名,返回签名结果
            // 参数说明:initParam:vctk控件初始化参数,authContent:认证原文,signSubject:证书版本者主题
            let signResult = detachSignStr(INIT_PARAM, original.original, '')
            if (signResult) {
                this.certAuth.original = original.original
                this.certAuth.originalData = original.original_data
                this.certAuth.signedData = signResult
                this.certAuth.authMode = AUTH_MODE.cert
                this.certAuth.remoteAddr = window.location.hostname
                await this.getPKIAuth(this.certAuth)
                let { CN } = this.getPKIUserInfo
                let [name, IDNumber] = CN.split(' ')
                let params = {
                    yhId: IDNumber
                }
                await this.thirdPartyLogin(params)
                getUserInfo('from-login', this.$route)
            }
        }
    } catch (e) {
        console.log(e)
    } finally {
        this.loading = false
    }
}

1、获取随机数

async getOriginal({ commit }){
    try {
        let data = await getOriginal({})
        return data
    } catch (e) {
        console.log(e,"获取随机数失败")
    }
},

2、调用 detachSignStr 签名

3、获取认证信息


async getPKIAuth({ commit }, params){
    try {
        let {data} = await getPKIAuth(params)
        if (Object.values(data.certAttributeNodeMap).length === 0) return
        let userInfoList = Object.values(data.certAttributeNodeMap)[0].split(",")
        let userInfo = {}
        userInfoList.forEach(item=>{
            let [key, value] = item.split("=")
            userInfo[key] = value
        })
        commit("setPKIUserInfo", userInfo)
    } catch (e) {
        console.log(e,"获取认证信息失败")
    }
},

4、登录

async thirdPartyLogin({commit}, params) {
    try {
        let {data} = await thirdPartyLogin(params)
        commit('setToken', data.access_token)
        commit('setTokenDetail', data)
    }catch (e) {
        console.log(e)
    }
},
上次更新:
贡献者: QiaoJiazhou