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 @@
}
},
"cqk-sy-ui": {
"version": "1.1.48",
"resolved": "https://registry.npmjs.org/cqk-sy-ui/-/cqk-sy-ui-1.1.48.tgz",
"integrity": "sha512-1x/KceNV+t1hppxBTX663FXtDHUb3M7k8QdDm8QpkZVpu90jRO8Iok0juXxgW87U/xly7rcDgKEJ3lbVdwM+ig==",
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/cqk-sy-ui/-/cqk-sy-ui-1.2.0.tgz",
"integrity": "sha512-0FV2qSan6EDELqmbebWVGkbKU6V2ybTVjN0C0zkf+Weaet+7q1Y6ZTFthn0Ca9yE9lc0IbNedzQeQGNbQYft6g==",
"requires": {
"axios": "^0.26.1",
"crypto-js": "^4.1.1",
......
......@@ -9,7 +9,7 @@
},
"dependencies": {
"axios": "^0.26.1",
"cqk-sy-ui": "^1.1.48",
"cqk-sy-ui": "^1.2.0",
"crypto-js": "^4.1.1",
"element-plus": "^2.1.9",
"js-md5": "^0.7.3",
......
<template>
<syTraceLoginPage
:set-pwd="setPwd"
:handle-login="handleLogin"
:send-verification-code="sendVerificationCode"
></syTraceLoginPage>
<!-- fake fields are a workaround for chrome autofill getting the wrong fields -->
<input style="display: none" type="text" name="fakeusernameremembered" />
<input style="display: none" type="password" name="fakepasswordremembered" />
<syTraceLoginPage
:set-pwd="setPwd"
:handle-login="handleLogin"
:send-verification-code="sendVerificationCode"
></syTraceLoginPage>
</template>
<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"
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,
};
if (res?.data) {
var message = "";
if (setPwdType === "setPwd") {
message = "密码设置成功";
} else if (setPwdType === "resetPwd") {
message = "密码重置成功";
}
ElMessage({
message: message,
type: "success",
});
return true;
} else {
return res?.msg;
}
};
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 {
data = {
phone: account,
pwd: md5(
String(pwd) +
md5(String(pwd.length))
),
code: code,
code_type: 0,
};
params = {
login_type: 2,
email: account,
pwd: md5(String(verificationStr) + md5(String(verificationStr.length))),
};
}
const res = await $ajax({
type: "post",
url: GO_URLS.setPwd,
params: data,
type: "post",
url: GO_URLS.login,
params: params,
});
if (res?.data) {
var message = "";
if (setPwdType === 'setPwd') {
message = "密码设置成功";
} else if (setPwdType === 'resetPwd') {
message = "密码重置成功";
}
ElMessage({
message: message,
type: "success",
});
return true;
}else{
return res?.msg;
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;
}
}
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 {
params = {
login_type: 2,
email: 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) {
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,
});
} 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) {
sessionStorage.setItem("login_type", '1');
storage.setLogin(
res.data,
{
login_type: 0,
phone: account,
pwd: verificationStr,
},
remember || false
);
router.push({ path: "/categoryManage" });
return true;
} else {
return res?.msg;
}
if (res && res.data) {
sessionStorage.setItem("login_type", "1");
storage.setLogin(
res.data,
{
login_type: 0,
phone: account,
pwd: verificationStr,
},
remember || false
);
router.push({ path: "/categoryManage" });
return true;
} else {
return false;
return res?.msg;
}
}
} else {
return false;
}
};
const sendVerificationCode = async (accountType: string, account: any, usedFor: string) => {
let res = null as any;
if (usedFor === 'login') {
if (accountType === 'phone') {
res = await $ajax({
type: "post",
url: GO_URLS.sendSms,
params: {
phone: account,
template_id: 0,
},
});
} else if (accountType === 'email') {
res = await $ajax({
url: GO_URLS.sendEmail,
type: "post",
params: {
email: account,
template_id: 0,
},
});
}
} else if (usedFor === 'setpwd') {
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,
},
});
}
const sendVerificationCode = async (
accountType: string,
account: any,
usedFor: string
) => {
let res = null as any;
if (usedFor === "login") {
if (accountType === "phone") {
res = await $ajax({
type: "post",
url: GO_URLS.sendSms,
params: {
phone: account,
template_id: 0,
},
});
} else if (accountType === "email") {
res = await $ajax({
url: GO_URLS.sendEmail,
type: "post",
params: {
email: account,
template_id: 0,
},
});
}
if (res) {
ElMessage({
message: "短信已发送",
type: "success",
});
return true;
} else return false;
}
</script>
\ No newline at end of file
} else if (usedFor === "setpwd") {
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) {
ElMessage({
message: "短信已发送",
type: "success",
});
return true;
} else return false;
};
</script>
......@@ -20,8 +20,8 @@ export default defineConfig({
server: {
proxy: {
"^/api": {
// target: "http://121.37.141.165:46790/",
target: "https://sy.8n.cn/api",
target: "http://121.37.141.165:46790/",
// target: "https://sy.8n.cn/api",
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