From 155ea74c3ca44e0545b72d63962645fd9f90b8f5 Mon Sep 17 00:00:00 2001 From: Adrien Castex Date: Mon, 12 Jun 2017 16:33:36 +0200 Subject: [PATCH] Changed 'addUser' of the 'SimpleUserManager' class to return the created user --- lib/user/simple/SimpleUserManager.d.ts | 2 +- lib/user/simple/SimpleUserManager.js | 4 +++- src/user/simple/SimpleUserManager.ts | 6 ++++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/user/simple/SimpleUserManager.d.ts b/lib/user/simple/SimpleUserManager.d.ts index 3c148197..5bc4e675 100644 --- a/lib/user/simple/SimpleUserManager.d.ts +++ b/lib/user/simple/SimpleUserManager.d.ts @@ -5,6 +5,6 @@ export declare class SimpleUserManager implements IUserManager { constructor(); getUserByName(name: string, callback: (error: Error, user: IUser) => void): void; getDefaultUser(callback: (user: IUser) => void): void; - addUser(name: string, password: string, isAdmin?: boolean): void; + addUser(name: string, password: string, isAdmin?: boolean): IUser; getUsers(callback: (error: Error, users: IUser[]) => void): void; } diff --git a/lib/user/simple/SimpleUserManager.js b/lib/user/simple/SimpleUserManager.js index 84884614..b6c4053e 100644 --- a/lib/user/simple/SimpleUserManager.js +++ b/lib/user/simple/SimpleUserManager.js @@ -19,7 +19,9 @@ var SimpleUserManager = (function () { }; SimpleUserManager.prototype.addUser = function (name, password, isAdmin) { if (isAdmin === void 0) { isAdmin = false; } - this.users[name] = new SimpleUser_1.SimpleUser(name, password, isAdmin, false); + var user = new SimpleUser_1.SimpleUser(name, password, isAdmin, false); + this.users[name] = user; + return user; }; SimpleUserManager.prototype.getUsers = function (callback) { var users = []; diff --git a/src/user/simple/SimpleUserManager.ts b/src/user/simple/SimpleUserManager.ts index af7d5d53..332d0b14 100644 --- a/src/user/simple/SimpleUserManager.ts +++ b/src/user/simple/SimpleUserManager.ts @@ -26,9 +26,11 @@ export class SimpleUserManager implements IUserManager callback(this.users.__default); } - addUser(name : string, password : string, isAdmin : boolean = false) + addUser(name : string, password : string, isAdmin : boolean = false) : IUser { - this.users[name] = new SimpleUser(name, password, isAdmin, false); + const user = new SimpleUser(name, password, isAdmin, false); + this.users[name] = user; + return user; } getUsers(callback : (error : Error, users : IUser[]) => void)