1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-28 00:06:53 +01:00
unleash.unleash/lib/routes/admin-api/user.js

38 lines
886 B
JavaScript
Raw Normal View History

'use strict';
2018-12-04 08:16:03 +01:00
const Controller = require('../controller');
2018-12-04 08:16:03 +01:00
class UserController extends Controller {
constructor(config) {
super(config);
2018-12-04 08:16:03 +01:00
this.get('/', this.getUser);
this.get('/logout', this.logout);
}
2018-12-04 08:16:03 +01:00
getUser(req, res) {
if (req.user) {
const user = Object.assign({}, req.user);
if (!this.config.extendedPermissions) {
delete user.permissions;
} else if (!Array.isArray(user.permissions)) {
user.permissions = [];
}
return res
.status(200)
.json(user)
.end();
} else {
return res.status(404).end();
}
2018-12-04 08:16:03 +01:00
}
2018-12-04 08:16:03 +01:00
logout(req, res) {
2018-01-17 09:46:16 +01:00
if (req.session) {
req.session = null;
}
res.redirect('/');
2018-12-04 08:16:03 +01:00
}
}
2018-01-17 09:46:16 +01:00
2018-12-04 08:16:03 +01:00
module.exports = UserController;