修改检查密码的逻辑,改为直接检查address是否一致
This commit is contained in:
parent
22abde8821
commit
8c43cfe55a
@ -27,7 +27,7 @@ import { parseUrl } from "./manage/SchemeManage";
|
||||
import {
|
||||
loadInternalWallet,
|
||||
loginByEmail,
|
||||
restoreWalletByMnemonic,
|
||||
verifyPassword,
|
||||
walletPreLogin,
|
||||
} from "./manage/WalletManage";
|
||||
import { EmailVerifySvr } from "./services/EmailVerifySvr";
|
||||
@ -115,6 +115,10 @@ export default class JCWallet {
|
||||
return walletPreLogin(channel);
|
||||
}
|
||||
|
||||
public verifyLocalPass(pass: string) {
|
||||
return verifyPassword(pass);
|
||||
}
|
||||
|
||||
public emailLogin(email: string, password: string) {
|
||||
return loginByEmail(email, password);
|
||||
}
|
||||
|
@ -98,6 +98,20 @@ export async function loginByEmail(email: string, password: string) {
|
||||
}
|
||||
|
||||
export async function loadInternalWallet(pass: string) {
|
||||
let walletEnv = new WalletEnv();
|
||||
let address = await prepareInternalWallet(pass);
|
||||
if (walletEnv.address && walletEnv.address !== address) {
|
||||
throw new ZError(10, "address not match, perhaps wrong password");
|
||||
}
|
||||
if (!walletEnv.address) {
|
||||
retry(() => uploadWalletInfo({ address }), MAX_UPLOAD_COUNT);
|
||||
}
|
||||
walletEnv.address = address;
|
||||
jsb.storeLocalPass(pass);
|
||||
return address;
|
||||
}
|
||||
|
||||
async function prepareInternalWallet(pass: string) {
|
||||
let walletEnv = new WalletEnv();
|
||||
console.log(JSON.stringify(walletEnv));
|
||||
if (!walletEnv.key) {
|
||||
@ -112,17 +126,17 @@ export async function loadInternalWallet(pass: string) {
|
||||
walletEnv.salt,
|
||||
pass
|
||||
);
|
||||
console.log("prepare wallet result: " + address);
|
||||
if (walletEnv.address && walletEnv.address !== address) {
|
||||
throw new ZError(10, "address not match, perhaps wrong password");
|
||||
}
|
||||
if (!walletEnv.address) {
|
||||
retry(() => uploadWalletInfo({ address }), MAX_UPLOAD_COUNT);
|
||||
}
|
||||
walletEnv.address = address;
|
||||
jsb.storeLocalPass(pass);
|
||||
return address;
|
||||
}
|
||||
/**
|
||||
* calc wallet address and check if address is same with walletEnv.address
|
||||
* @param pass
|
||||
* @returns
|
||||
*/
|
||||
export async function verifyPassword(pass: string) {
|
||||
let address = await prepareInternalWallet(pass);
|
||||
return new WalletEnv().address === address;
|
||||
}
|
||||
|
||||
export function walletSign(str: string) {
|
||||
let result = jsb.walletSign(str);
|
||||
|
Loading…
x
Reference in New Issue
Block a user