1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-10-18 20:09:08 +02:00
unleash.unleash/lib/routes/admin-api/user.js

36 lines
779 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(perms) {
super(perms);
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.extendedPermissions) {
delete 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;