mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-23 23:19:40 +01:00
core: use the new login flow in all tests
This commit is contained in:
committed by
Abdullah Atta
parent
65cae7888e
commit
22871d8baf
@@ -147,51 +147,6 @@ class UserManager {
|
||||
EV.publish(EVENTS.userLoggedIn, user);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Please use `authenticateEmail`, `authenticateMultiFactorCode` & `authenticatePassword` for login
|
||||
*/
|
||||
async login(email, password, hashedPassword = undefined) {
|
||||
return this._login({ email, password, hashedPassword });
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Please use `authenticateEmail`, `authenticateMultiFactorCode` & `authenticatePassword` for login
|
||||
*/
|
||||
async mfaLogin(email, password, { code, method }) {
|
||||
return this._login({ email, password, code, method });
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
async _login({ email, password, hashedPassword, code, method }) {
|
||||
email = email && email.toLowerCase();
|
||||
|
||||
if (!hashedPassword && password) {
|
||||
hashedPassword = await this._storage.hash(password, email);
|
||||
}
|
||||
|
||||
await this.tokenManager.saveToken(
|
||||
await http.post(`${constants.AUTH_HOST}${ENDPOINTS.token}`, {
|
||||
username: email,
|
||||
password: hashedPassword,
|
||||
grant_type: code ? "mfa" : "password",
|
||||
scope: "notesnook.sync offline_access openid IdentityServerApi",
|
||||
client_id: "notesnook",
|
||||
"mfa:code": code,
|
||||
"mfa:method": method
|
||||
})
|
||||
);
|
||||
|
||||
const user = await this.fetchUser();
|
||||
await this._storage.deriveCryptoKey(`_uk_@${user.email}`, {
|
||||
password,
|
||||
salt: user.salt
|
||||
});
|
||||
|
||||
EV.publish(EVENTS.userLoggedIn, user);
|
||||
}
|
||||
|
||||
async getSessions() {
|
||||
const token = await this.tokenManager.getAccessToken();
|
||||
if (!token) return;
|
||||
|
||||
Reference in New Issue
Block a user