developed initial version of new login page

This commit is contained in:
Sheen Capadngan
2023-04-27 23:10:27 +08:00
parent 2dd1570200
commit dfb84e9932
7 changed files with 239 additions and 44 deletions
@@ -26,20 +26,33 @@ interface IsLoginSuccessful {
* @param {string} password - password of user to log in
*/
const attemptLogin = async (
email: string,
password: string
{
email,
password,
userId,
}: {
email: string;
userId?: string;
password: string;
}
): Promise<IsLoginSuccessful> => {
const username = userId ?? email;
const telemetry = new Telemetry().getInstance();
return new Promise((resolve, reject) => {
client.init(
{
username: email,
username,
password
},
async () => {
try {
const clientPublicKey = client.getPublicKey();
const { serverPublicKey, salt } = await login1(email, clientPublicKey);
const { serverPublicKey, salt } = await login1({
email,
clientPublicKey,
userId,
});
client.setSalt(salt);
client.setServerPublicKey(serverPublicKey);
@@ -57,8 +70,11 @@ const attemptLogin = async (
iv,
tag
} = await login2(
email,
clientProof
{
email,
userId,
clientProof,
}
);
if (mfaEnabled) {
@@ -137,4 +153,4 @@ const attemptLogin = async (
});
};
export default attemptLogin;
export default attemptLogin;