jwt-logout-app
Version:
A JWT Logout app that maitaines a dictionary of JWTs mapped to a userid which can then be used for performig logout when using JWT for sign-in
36 lines • 1.3 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
let users = [];
class JWTDictionary {
/**
*
*/
constructor() {
// console.log("Creating new instance of JWT Dictionary");
}
AddUser(user) {
console.log("Adding new user to dictionary");
if (users.indexOf(user) == -1) {
users.push(user);
console.log("User:" + user.UserId + "added to dictionary");
}
}
GetUserByToken(token) {
console.log("Getting user with token:" + token + " from the dictionary");
let foundUser = users.find(x => x.Token === token);
console.log("Found user with Id:" + foundUser.UserId + " in dictionary");
return foundUser;
}
GetUserBYUserId(userId) {
console.log("Getting user with Id:" + userId + " from the dictionary");
let foundUser = users.find(x => x.UserId === userId);
console.log("Found user with Id:" + foundUser.UserId + " in dictionary");
return foundUser;
}
RemoveUser(user) {
console.log("Removing user with Id:" + user.UserId + " from the dictionary");
users = users.filter(x => x !== user);
}
}
exports.default = JWTDictionary;
//# sourceMappingURL=jwt-dict.js.map