mirror of
https://github.com/rr-/szurubooru.git
synced 2025-07-17 08:26:24 +00:00
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:
@ -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');
|
||||
|
||||
|
Reference in New Issue
Block a user