|
@@ -58,9 +58,10 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import {getCodeImg} from "@/api/login";
|
|
|
+import {getCodeImg, getSecretKey} from "@/api/login";
|
|
|
import Cookies from "js-cookie";
|
|
|
import {decrypt, encrypt} from '@/utils/jsencrypt'
|
|
|
+import {encryptedData} from "@/api/tool/encrypt";
|
|
|
|
|
|
export default {
|
|
|
name: "Login",
|
|
@@ -136,14 +137,23 @@ export default {
|
|
|
Cookies.remove("password");
|
|
|
Cookies.remove('rememberMe');
|
|
|
}
|
|
|
- this.$store.dispatch("Login", this.loginForm).then(() => {
|
|
|
- this.$router.push({path: this.redirect || "/"}).catch(() => {
|
|
|
+ //登录前先获取密码加密传输的公钥,对密码进行加密
|
|
|
+ getSecretKey().then((res) => {
|
|
|
+ const encryptedPassword = encryptedData(
|
|
|
+ res.data,
|
|
|
+ this.loginForm.password
|
|
|
+ );
|
|
|
+ this.loginForm.password = encryptedPassword;
|
|
|
+
|
|
|
+ this.$store.dispatch("Login", this.loginForm).then(() => {
|
|
|
+ this.$router.push({path: "/"}).catch(() => {
|
|
|
+ });
|
|
|
+ }).catch(() => {
|
|
|
+ this.loading = false;
|
|
|
+ if (this.captchaEnabled) {
|
|
|
+ this.getCode();
|
|
|
+ }
|
|
|
});
|
|
|
- }).catch(() => {
|
|
|
- this.loading = false;
|
|
|
- if (this.captchaEnabled) {
|
|
|
- this.getCode();
|
|
|
- }
|
|
|
});
|
|
|
}
|
|
|
});
|