修改检查密码的逻辑,改为直接检查address是否一致
This commit is contained in:
parent
22abde8821
commit
8c43cfe55a
@ -27,7 +27,7 @@ import { parseUrl } from "./manage/SchemeManage";
|
|||||||
import {
|
import {
|
||||||
loadInternalWallet,
|
loadInternalWallet,
|
||||||
loginByEmail,
|
loginByEmail,
|
||||||
restoreWalletByMnemonic,
|
verifyPassword,
|
||||||
walletPreLogin,
|
walletPreLogin,
|
||||||
} from "./manage/WalletManage";
|
} from "./manage/WalletManage";
|
||||||
import { EmailVerifySvr } from "./services/EmailVerifySvr";
|
import { EmailVerifySvr } from "./services/EmailVerifySvr";
|
||||||
@ -115,6 +115,10 @@ export default class JCWallet {
|
|||||||
return walletPreLogin(channel);
|
return walletPreLogin(channel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public verifyLocalPass(pass: string) {
|
||||||
|
return verifyPassword(pass);
|
||||||
|
}
|
||||||
|
|
||||||
public emailLogin(email: string, password: string) {
|
public emailLogin(email: string, password: string) {
|
||||||
return loginByEmail(email, password);
|
return loginByEmail(email, password);
|
||||||
}
|
}
|
||||||
|
@ -98,6 +98,20 @@ export async function loginByEmail(email: string, password: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function loadInternalWallet(pass: 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();
|
let walletEnv = new WalletEnv();
|
||||||
console.log(JSON.stringify(walletEnv));
|
console.log(JSON.stringify(walletEnv));
|
||||||
if (!walletEnv.key) {
|
if (!walletEnv.key) {
|
||||||
@ -112,17 +126,17 @@ export async function loadInternalWallet(pass: string) {
|
|||||||
walletEnv.salt,
|
walletEnv.salt,
|
||||||
pass
|
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;
|
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) {
|
export function walletSign(str: string) {
|
||||||
let result = jsb.walletSign(str);
|
let result = jsb.walletSign(str);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user