浏览代码

处理认证接口

reghao 3 年之前
父节点
当前提交
d0d01ef22f
共有 1 个文件被更改,包括 8 次插入7 次删除
  1. 8 7
      src/components/login-form.vue

+ 8 - 7
src/components/login-form.vue

@@ -65,7 +65,8 @@ export default {
       password: '',
       captcha: '',
       rememberMe: false,
-      pubkey: ''
+      pubkey: '',
+      pubkeyR: ''
     }
   },
   created() {
@@ -73,15 +74,14 @@ export default {
     this.fetchPubkey()
   },
   methods: {
-    encryptPassword(password) {
+    encryptPassword(password, pubkey, pubkeyR) {
       var encryptor = new JSEncrypt()
-      encryptor.setPublicKey(this.pubkey)
-      const r = encryptor.encrypt(password)
-      console.log(r)
+      encryptor.setPublicKey(pubkey)
+      return encryptor.encrypt(pubkeyR + password)
     },
     submitLogin() {
       const username = this.username
-      const password = this.$options.methods.encryptPassword(this.password)
+      const password = this.$options.methods.encryptPassword(this.password, this.pubkey, this.pubkeyR)
       // const password = this.password
       const captcha = this.captcha
       const r = this.r
@@ -116,7 +116,8 @@ export default {
     fetchPubkey() {
       getPubkey().then(res => {
         if (res.code === 0) {
-          this.pubkey = res.data
+          this.pubkey = res.data.pubkey
+          this.pubkeyR = res.data.r
         } else {
           alert(res.data)
         }