generated from youfool-project/youfool-prj-springboot-template
AI generated changes for conversation 37
This commit is contained in:
parent
b5b53df7d9
commit
3fedfd5a60
|
|
@ -145,21 +145,7 @@
|
|||
</div>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/jsencrypt@3.2.1/bin/jsencrypt.min.js"></script>
|
||||
<script>
|
||||
// 获取公钥
|
||||
let publicKey = '';
|
||||
fetch('/course/user/auth/publicKey')
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.code === 200) {
|
||||
publicKey = data.data;
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('获取公钥失败:', error);
|
||||
});
|
||||
|
||||
// 登录表单提交
|
||||
document.getElementById('loginForm').addEventListener('submit', async function(e) {
|
||||
e.preventDefault();
|
||||
|
|
@ -169,20 +155,10 @@
|
|||
const errorMessage = document.getElementById('errorMessage');
|
||||
|
||||
try {
|
||||
// 加密密码
|
||||
const encrypt = new JSEncrypt();
|
||||
encrypt.setPublicKey(publicKey);
|
||||
const encryptedPassword = encrypt.encrypt(password);
|
||||
|
||||
if (!encryptedPassword) {
|
||||
throw new Error('密码加密失败');
|
||||
}
|
||||
|
||||
// 发送登录请求
|
||||
const response = await axios.post('/course/user/auth/login', {
|
||||
username: username,
|
||||
password: encryptedPassword,
|
||||
encrypt: true
|
||||
password: password
|
||||
});
|
||||
|
||||
if (response.data.code === 200) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue