client/auth: show errors early in controllers

In other words, verify the privileges client-side before issuing an
request to the server. This commit focuses on routing (e.g. clicking a
link while not logged in), rather than DOM element visibility that
should be already taken care of.
This commit is contained in:
rr-
2016-08-23 21:18:03 +02:00
parent 803a1350fa
commit 08c6c2c145
11 changed files with 81 additions and 3 deletions

View File

@ -7,9 +7,16 @@ const topNavigation = require('../models/top_navigation.js');
const PageController = require('../controllers/page_controller.js');
const UsersHeaderView = require('../views/users_header_view.js');
const UsersPageView = require('../views/users_page_view.js');
const EmptyView = require('../views/empty_view.js');
class UserListController {
constructor(ctx) {
if (!api.hasPrivilege('users:list')) {
this._view = new EmptyView();
this._view.showError('You don\'t have privileges to view users.');
return;
}
topNavigation.activate('users');
topNavigation.setTitle('Listing users');