split oidc into server and clients
This commit is contained in:
+15
-1
@@ -16,7 +16,8 @@ exports = module.exports = {
|
||||
setTwoFactorAuthenticationSecret,
|
||||
enableTwoFactorAuthentication,
|
||||
disableTwoFactorAuthentication,
|
||||
setNotificationConfig
|
||||
setNotificationConfig,
|
||||
destroyUserSession
|
||||
};
|
||||
|
||||
const assert = require('assert'),
|
||||
@@ -24,7 +25,9 @@ const assert = require('assert'),
|
||||
BoxError = require('../boxerror.js'),
|
||||
HttpError = require('connect-lastmile').HttpError,
|
||||
HttpSuccess = require('connect-lastmile').HttpSuccess,
|
||||
oidcServer = require('../oidcserver.js'),
|
||||
safe = require('safetydance'),
|
||||
tokens = require('../tokens.js'),
|
||||
userDirectory = require('../user-directory.js'),
|
||||
users = require('../users.js');
|
||||
|
||||
@@ -228,3 +231,14 @@ async function setNotificationConfig(req, res, next) {
|
||||
|
||||
next(new HttpSuccess(204, {}));
|
||||
}
|
||||
|
||||
async function destroyUserSession(req, res, next) {
|
||||
assert.strictEqual(typeof req.user, 'object');
|
||||
|
||||
const [error] = await safe(oidcServer.revokeByUserId(req.user.id));
|
||||
if (error) return next(BoxError.toHttpError(error));
|
||||
|
||||
await safe(tokens.del(req.token.id));
|
||||
|
||||
next(new HttpSuccess(204));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user