From 91bd9f256fe17be27249979e2b940f766e9801c9 Mon Sep 17 00:00:00 2001 From: Braun Patrik Date: Mon, 10 Jul 2017 18:08:39 +0200 Subject: [PATCH] file based user manager fixed --- backend/model/memory/UserManager.ts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/backend/model/memory/UserManager.ts b/backend/model/memory/UserManager.ts index 55a5a730..37c88945 100644 --- a/backend/model/memory/UserManager.ts +++ b/backend/model/memory/UserManager.ts @@ -54,12 +54,18 @@ export class UserManager implements IUserManager { public async find(filter: any) { let pass = filter.password; delete filter.password; - return this.db.get("users").filter((u: UserDTO) => { - if (pass && !PasswordHelper.comparePassword(pass, u.password)) { - return false; + const users = await this.db.get("users"); + let i = users.length; + while (i--) { + if (pass && !(await PasswordHelper.comparePassword(pass, users[i].password))) { + users.splice(i, 1); + continue; } - Utils.equalsFilter(u, filter) - }); + if (Utils.equalsFilter(users[i], filter) == false) { + users.splice(i, 1); + } + } + return users; } public async createUser(user: UserDTO) {