fix signup/change password can not login

This commit is contained in:
xiaomlove
2025-05-22 01:52:52 +07:00
parent 3dfe0cbd27
commit c3aa540571
2 changed files with 5 additions and 5 deletions
+3 -3
View File
@@ -1566,11 +1566,11 @@ async function login(username, password, jqForm) {
return
}
const clientHashedPassword = await sha256(password);
const clientHashedPassword = sha256(password);
const serverSideHash = await sha256(challengeData.data.secret + clientHashedPassword);
const serverSideHash = sha256(challengeData.data.secret + clientHashedPassword);
const clientResponse = await hmacSha256(challengeData.data.challenge, serverSideHash);
const clientResponse = hmacSha256(challengeData.data.challenge, serverSideHash);
jqForm.find("input[name=response]").val(clientResponse)
jqForm.submit()
} catch (error) {
+2 -2
View File
@@ -407,7 +407,7 @@ function DelRow(anchor){
// 工具函数:SHA-256哈希
// 因 crypto.subtle 在 http 下不可用,故引入三方库
async function sha256(message) {
function sha256(message) {
// const msgBuffer = new TextEncoder().encode(message);
// const hashBuffer = await crypto.subtle.digest('SHA-256', msgBuffer);
// const hashArray = Array.from(new Uint8Array(hashBuffer));
@@ -416,7 +416,7 @@ async function sha256(message) {
}
// 工具函数:HMAC-SHA256
async function hmacSha256(key, message) {
function hmacSha256(key, message) {
// const encoder = new TextEncoder();
// const keyData = encoder.encode(key);
// const messageData = encoder.encode(message);