UI authentication improvements
This commit is contained in:
1 parent
77563fc85e
commit
8533ee7f2e
4 files changed
+44
-28
No files matched your search
@@ -168,15 +168,15 @@ export async function putResource(resource, id, data): Promise<void> {
|
||||
await del("presets_hash");
|
||||
}
|
||||
|
||||
export function authSimple(snapshot, username, password): Promise<string[]> {
|
||||
export function authLocal(snapshot, username, password): Promise<boolean> {
|
||||
return new Promise((resolve, reject) => {
|
||||
const users = getUsers(snapshot);
|
||||
const user = users[username];
|
||||
if (!user || !user.password) return void resolve(null);
|
||||
hashPassword(password, user.salt)
|
||||
.then(hash => {
|
||||
if (hash === user.password) resolve(user.roles);
|
||||
else resolve(null);
|
||||
if (hash === user.password) resolve(true);
|
||||
else resolve(false);
|
||||
})
|
||||
.catch(reject);
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user