Pārlūkot izejas kodu

#add 登录添加加密

jc-wangyt 4 dienas atpakaļ
vecāks
revīzija
0a1d4ec4da
2 mainītis faili ar 19 papildinājumiem un 13 dzēšanām
  1. 6 3
      src/utils/jsencrypt.js
  2. 13 10
      src/views/login.vue

+ 6 - 3
src/utils/jsencrypt.js

@@ -2,9 +2,12 @@ import JSEncrypt from 'jsencrypt/bin/jsencrypt.min'
 
 // 密钥对生成 http://web.chacuo.net/netrsakeypair
 
-const publicKey = 'MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAKoR8mX0rGKLqzcWmOzbfj64K8ZIgOdH\n' +
-  'nzkXSOVOZbFu/TJhZ7rFAN+eaGkl3C4buccQd/EjEsj9ir7ijT7h96MCAwEAAQ=='
-
+// const publicKey = 'MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAKoR8mX0rGKLqzcWmOzbfj64K8ZIgOdH\n' +
+//   'nzkXSOVOZbFu/TJhZ7rFAN+eaGkl3C4buccQd/EjEsj9ir7ijT7h96MCAwEAAQ=='
+const publicKey = `MIGeMA0GCSqGSIb3DQEBAQUAA4GMADCBiAKBgEmLg1maj2xOSCgFYvQjHgc/542Y
+Vz4zSPsY/ngzlQNZqPVT+zUSuwTqIMxn4NapspQdfRpuOVNfe8ZJep7H8zvOt78t
+k31CA7Uz3konemuaLc96w+GhUVivH6CMavYGjWAZdHUVtfnmOiUZQEAtrGQZRluA
+PKCsWfpQuEQZ3XKVAgMBAAE=`
 const privateKey = 'MIIBVAIBADANBgkqhkiG9w0BAQEFAASCAT4wggE6AgEAAkEAqhHyZfSsYourNxaY\n' +
   '7Nt+PrgrxkiA50efORdI5U5lsW79MmFnusUA355oaSXcLhu5xxB38SMSyP2KvuKN\n' +
   'PuH3owIDAQABAkAfoiLyL+Z4lf4Myxk6xUDgLaWGximj20CUf+5BKKnlrK+Ed8gA\n' +

+ 13 - 10
src/views/login.vue

@@ -56,7 +56,7 @@ export default {
       footerContent: defaultSettings.footerContent,
       codeUrl: "",
       loginForm: {
-        username: "admin",
+        username: "test1",
         password: "Welcome1#",
         rememberMe: false,
         code: "",
@@ -116,15 +116,18 @@ export default {
       this.$refs.loginForm.validate(valid => {
         if (valid) {
           this.loading = true
-          if (this.loginForm.rememberMe) {
-            Cookies.set("username", this.loginForm.username, { expires: 30 })
-            Cookies.set("password", encrypt(this.loginForm.password), { expires: 30 })
-            Cookies.set('rememberMe', this.loginForm.rememberMe, { expires: 30 })
-          } else {
-            Cookies.remove("username")
-            Cookies.remove("password")
-            Cookies.remove('rememberMe')
-          }
+          // if (this.loginForm.rememberMe) {
+          //   Cookies.set("username", this.loginForm.username, { expires: 30 })
+          //   Cookies.set("password", encrypt(this.loginForm.password), { expires: 30 })
+          //   Cookies.set('rememberMe', this.loginForm.rememberMe, { expires: 30 })
+          // } else {
+          //   Cookies.remove("username")
+          //   Cookies.remove("password")
+          //   Cookies.remove('rememberMe')
+          // }
+          this.loginForm.username = encrypt(this.loginForm.username)
+          this.loginForm.password = encrypt(this.loginForm.password)
+          console.log(this.loginForm,'=--------------')
           this.$store.dispatch("Login", this.loginForm).then(() => {
             this.$router.push({ path: this.redirect || "/" }).catch(() => { })
           }).catch(() => {