Skip to content

Commit

Permalink
Changed 'addUser' of the 'SimpleUserManager' class to return the crea…
Browse files Browse the repository at this point in the history
…ted user
  • Loading branch information
AdrienCastex committed Jun 12, 2017
1 parent b5b81f3 commit 155ea74
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/user/simple/SimpleUserManager.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
4 changes: 3 additions & 1 deletion lib/user/simple/SimpleUserManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
Expand Down
6 changes: 4 additions & 2 deletions src/user/simple/SimpleUserManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 155ea74

Please sign in to comment.