@accounts/server
Advanced tools
Comparing version 0.3.0-beta.29 to 0.3.0-beta.30
@@ -108,2 +108,14 @@ import * as Emittery from 'emittery'; | ||
updateProfile(userId: string, profile: object): Promise<object>; | ||
/** | ||
* @description Deactivate a user, the user will not be able to login until his account is reactivated. | ||
* @param {string} userId - User id. | ||
* @returns {Promise<void>} - Return a Promise. | ||
*/ | ||
deactivateUser(userId: string): Promise<void>; | ||
/** | ||
* @description Activate a user. | ||
* @param {string} userId - User id. | ||
* @returns {Promise<void>} - Return a Promise. | ||
*/ | ||
activateUser(userId: string): Promise<void>; | ||
prepareMail(to: string, token: string, user: User, pathFragment: string, emailTemplate: EmailTemplateType, from: string): any; | ||
@@ -110,0 +122,0 @@ sanitizeUser(user: User): User; |
@@ -128,6 +128,9 @@ "use strict"; | ||
user = _a.sent(); | ||
hooksInfo.user = user; | ||
if (!user) { | ||
throw new Error("Service " + serviceName + " was not able to authenticate user"); | ||
} | ||
hooksInfo.user = user; | ||
if (user.deactivated) { | ||
throw new Error('Your account has been deactivated'); | ||
} | ||
// Let the user validate the login attempt | ||
@@ -535,2 +538,26 @@ return [4 /*yield*/, this.hooks.emitSerial(server_hooks_1.ServerHooks.ValidateLogin, hooksInfo)]; | ||
}; | ||
/** | ||
* @description Deactivate a user, the user will not be able to login until his account is reactivated. | ||
* @param {string} userId - User id. | ||
* @returns {Promise<void>} - Return a Promise. | ||
*/ | ||
AccountsServer.prototype.deactivateUser = function (userId) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, this.db.setUserDeactivated(userId, true)]; | ||
}); | ||
}); | ||
}; | ||
/** | ||
* @description Activate a user. | ||
* @param {string} userId - User id. | ||
* @returns {Promise<void>} - Return a Promise. | ||
*/ | ||
AccountsServer.prototype.activateUser = function (userId) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, this.db.setUserDeactivated(userId, false)]; | ||
}); | ||
}); | ||
}; | ||
AccountsServer.prototype.prepareMail = function (to, token, user, pathFragment, emailTemplate, from) { | ||
@@ -537,0 +564,0 @@ if (this.options.prepareMail) { |
{ | ||
"name": "@accounts/server", | ||
"version": "0.3.0-beta.29", | ||
"version": "0.3.0-beta.30", | ||
"description": "Fullstack authentication and accounts-management", | ||
@@ -49,3 +49,3 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"@accounts/types": "^0.3.0-beta.29", | ||
"@accounts/types": "^0.3.0-beta.30", | ||
"@types/jsonwebtoken": "7.2.8", | ||
@@ -52,0 +52,0 @@ "emittery": "0.4.1", |
Sorry, the diff of this file is not supported yet
62743
975