1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-11-10 01:19:53 +01:00
unleash.unleash/src/lib/routes/admin-api/user.js
2021-04-11 22:39:44 +02:00

38 lines
856 B
JavaScript

'use strict';
const Controller = require('../controller');
class UserController extends Controller {
constructor(config) {
super(config);
this.get('/', this.getUser);
this.get('/logout', this.logout);
}
getUser(req, res) {
if (req.user) {
const user = { ...req.user };
delete user.permissions; // TODO: remove
return res
.status(200)
.json(user)
.end();
}
return res.status(404).end();
}
// Deprecated, use "/logout" instead. Will be removed in v4.
logout(req, res) {
if (req.session) {
req.session = null;
}
if (req.logout) {
req.logout();
}
res.redirect(`${this.config.baseUriPath}/`);
}
}
module.exports = UserController;