Commit eeec60b6 authored by chenqikuai's avatar chenqikuai

fix: 修复密码自动填充的问题

parent 4b41edb8
tar -czf sy2.tar sy2
scp sy2.tar root@121.37.141.165:/var/www/html/personal/sy2.tar
rm -rf sy2.tar
rm -rf sy2
ssh root@121.37.141.165 'cd /var/www/html/personal/ && rm -rf sy2 && tar -xzf sy2.tar && rm -rf sy2.tar'
echo 'done. 👉 http://121.37.141.165:8903'
...@@ -822,9 +822,9 @@ ...@@ -822,9 +822,9 @@
} }
}, },
"cqk-sy-ui": { "cqk-sy-ui": {
"version": "1.1.48", "version": "1.2.0",
"resolved": "https://registry.npmjs.org/cqk-sy-ui/-/cqk-sy-ui-1.1.48.tgz", "resolved": "https://registry.npmjs.org/cqk-sy-ui/-/cqk-sy-ui-1.2.0.tgz",
"integrity": "sha512-1x/KceNV+t1hppxBTX663FXtDHUb3M7k8QdDm8QpkZVpu90jRO8Iok0juXxgW87U/xly7rcDgKEJ3lbVdwM+ig==", "integrity": "sha512-0FV2qSan6EDELqmbebWVGkbKU6V2ybTVjN0C0zkf+Weaet+7q1Y6ZTFthn0Ca9yE9lc0IbNedzQeQGNbQYft6g==",
"requires": { "requires": {
"axios": "^0.26.1", "axios": "^0.26.1",
"crypto-js": "^4.1.1", "crypto-js": "^4.1.1",
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
}, },
"dependencies": { "dependencies": {
"axios": "^0.26.1", "axios": "^0.26.1",
"cqk-sy-ui": "^1.1.48", "cqk-sy-ui": "^1.2.0",
"crypto-js": "^4.1.1", "crypto-js": "^4.1.1",
"element-plus": "^2.1.9", "element-plus": "^2.1.9",
"js-md5": "^0.7.3", "js-md5": "^0.7.3",
......
<template> <template>
<syTraceLoginPage <!-- fake fields are a workaround for chrome autofill getting the wrong fields -->
:set-pwd="setPwd" <input style="display: none" type="text" name="fakeusernameremembered" />
:handle-login="handleLogin" <input style="display: none" type="password" name="fakepasswordremembered" />
:send-verification-code="sendVerificationCode" <syTraceLoginPage
></syTraceLoginPage> :set-pwd="setPwd"
:handle-login="handleLogin"
:send-verification-code="sendVerificationCode"
></syTraceLoginPage>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { syTraceLoginPage, GO_URLS } from "cqk-sy-ui";
import { ElMessage } from "element-plus";
import { $ajax } from "@/service/index";
import * as storage from "@/service/storage";
import md5 from "js-md5";
import { router } from "@/router";
const setPwd: any = async (
setPwdType: string,
accountType: string,
account: any,
code: any,
pwd: string | any[]
) => {
let data = {};
if (accountType === "email") {
data = {
email: account,
pwd: md5(String(pwd) + md5(String(pwd.length))),
code: code,
code_type: 1,
};
} else {
data = {
phone: account,
pwd: md5(String(pwd) + md5(String(pwd.length))),
code: code,
code_type: 0,
};
}
const res = await $ajax({
type: "post",
url: GO_URLS.setPwd,
params: data,
});
import { syTraceLoginPage, GO_URLS } from "cqk-sy-ui" if (res?.data) {
import { ElMessage } from "element-plus" var message = "";
import { $ajax } from "@/service/index" if (setPwdType === "setPwd") {
import * as storage from "@/service/storage" message = "密码设置成功";
import md5 from 'js-md5' } else if (setPwdType === "resetPwd") {
import { router } from "@/router" message = "密码重置成功";
const setPwd: any = async (setPwdType: string, accountType: string, account: any, code: any, pwd: string | any[]) => { }
let data = {}; ElMessage({
if (accountType === 'email') { message: message,
data = { type: "success",
email: account, });
pwd: md5( return true;
String(pwd) + } else {
md5(String(pwd.length)) return res?.msg;
), }
code: code, };
code_type: 1, const handleLogin: any = async (
}; accountType: string,
account: any,
verificationMethod: string,
verificationStr: any,
remember: any,
setError: any
) => {
if (accountType === "email") {
let params = {};
if (verificationMethod === "code") {
params = {
login_type: 3,
email: account,
code: verificationStr,
};
} else { } else {
data = { params = {
phone: account, login_type: 2,
pwd: md5( email: account,
String(pwd) + pwd: md5(String(verificationStr) + md5(String(verificationStr.length))),
md5(String(pwd.length)) };
),
code: code,
code_type: 0,
};
} }
const res = await $ajax({ const res = await $ajax({
type: "post", type: "post",
url: GO_URLS.setPwd, url: GO_URLS.login,
params: data, params: params,
}); });
if (res?.data) { if (res && res.data) {
var message = ""; sessionStorage.setItem("login_type", "2");
if (setPwdType === 'setPwd') { if (accountType === "email") {
message = "密码设置成功"; storage.setLogin(
} else if (setPwdType === 'resetPwd') { res.data,
message = "密码重置成功"; {
} login_type: 2,
ElMessage({ email: account,
message: message, pwd: verificationMethod,
type: "success", },
}); remember || false
return true; );
}else{ }
return res?.msg; router.push({ path: "/categoryManage" });
return true;
} else {
return res?.msg;
} }
} } else if (accountType === "phone") {
const handleLogin: any = async (accountType: string, account: any, verificationMethod: string, verificationStr: any, remember: any, setError: any) => { let params = {};
if (accountType === 'email') { if (verificationMethod === "code") {
let params = {}; params = {
if (verificationMethod === 'code') { login_type: 1,
params = { phone: account,
login_type: 3, code: verificationStr,
email: account, };
code: verificationStr, } else {
}; params = {
} else { login_type: 0,
params = { phone: account,
login_type: 2, pwd: md5(String(verificationStr) + md5(String(verificationStr.length))),
email: account, };
pwd: md5( }
String(verificationStr) + md5(String(verificationStr.length)) const res = await $ajax({
) type: "post",
}; url: GO_URLS.login,
} params: params,
const res = await $ajax({ });
type: "post",
url: GO_URLS.login,
params: params,
});
if (res && res.data) {
sessionStorage.setItem("login_type", '2');
if (accountType === 'email') {
storage.setLogin(
res.data,
{
login_type: 2,
email: account,
pwd: verificationMethod,
},
remember || false
);
}
router.push({ path: "/categoryManage" });
return true;
} else {
return res?.msg;
}
} else if (accountType === 'phone') {
let params = {};
if (verificationMethod === 'code') {
params = {
login_type: 1,
phone: account,
code: verificationStr,
};
} else {
params = {
login_type: 0,
phone: account,
pwd: md5(
String(verificationStr) + md5(String(verificationStr.length))
),
};
}
const res = await $ajax({
type: "post",
url: GO_URLS.login,
params: params,
});
if (res && res.data) { if (res && res.data) {
sessionStorage.setItem("login_type", '1'); sessionStorage.setItem("login_type", "1");
storage.setLogin( storage.setLogin(
res.data, res.data,
{ {
login_type: 0, login_type: 0,
phone: account, phone: account,
pwd: verificationStr, pwd: verificationStr,
}, },
remember || false remember || false
); );
router.push({ path: "/categoryManage" }); router.push({ path: "/categoryManage" });
return true; return true;
} else {
return res?.msg;
}
} else { } else {
return false; return res?.msg;
} }
} } else {
return false;
}
};
const sendVerificationCode = async (accountType: string, account: any, usedFor: string) => { const sendVerificationCode = async (
let res = null as any; accountType: string,
if (usedFor === 'login') { account: any,
if (accountType === 'phone') { usedFor: string
res = await $ajax({ ) => {
type: "post", let res = null as any;
url: GO_URLS.sendSms, if (usedFor === "login") {
params: { if (accountType === "phone") {
phone: account, res = await $ajax({
template_id: 0, type: "post",
}, url: GO_URLS.sendSms,
}); params: {
} else if (accountType === 'email') { phone: account,
res = await $ajax({ template_id: 0,
url: GO_URLS.sendEmail, },
type: "post", });
params: { } else if (accountType === "email") {
email: account, res = await $ajax({
template_id: 0, url: GO_URLS.sendEmail,
}, type: "post",
}); params: {
} email: account,
} else if (usedFor === 'setpwd') { template_id: 0,
if (accountType === 'phone') { },
res = await $ajax({ });
type: "post",
url: GO_URLS.sendSms,
params: {
phone: account,
template_id: 1,
},
});
} else if (accountType === 'email') {
res = await $ajax({
url: GO_URLS.sendEmail,
type: "post",
params: {
email: account,
template_id: 1,
},
});
}
} }
if (res) { } else if (usedFor === "setpwd") {
ElMessage({ if (accountType === "phone") {
message: "短信已发送", res = await $ajax({
type: "success", type: "post",
}); url: GO_URLS.sendSms,
return true; params: {
} else return false; phone: account,
} template_id: 1,
</script> },
\ No newline at end of file });
} else if (accountType === "email") {
res = await $ajax({
url: GO_URLS.sendEmail,
type: "post",
params: {
email: account,
template_id: 1,
},
});
}
}
if (res) {
ElMessage({
message: "短信已发送",
type: "success",
});
return true;
} else return false;
};
</script>
...@@ -20,8 +20,8 @@ export default defineConfig({ ...@@ -20,8 +20,8 @@ export default defineConfig({
server: { server: {
proxy: { proxy: {
"^/api": { "^/api": {
// target: "http://121.37.141.165:46790/", target: "http://121.37.141.165:46790/",
target: "https://sy.8n.cn/api", // target: "https://sy.8n.cn/api",
changeOrigin: true, changeOrigin: true,
}, },
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment