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:
@ -12,12 +12,20 @@ const EmptyView = require('../views/empty_view.js');
|
||||
|
||||
class UserController {
|
||||
constructor(ctx, section) {
|
||||
topNavigation.setTitle('User ' + ctx.parameters.name);
|
||||
User.get(ctx.parameters.name).then(user => {
|
||||
const userName = ctx.parameters.name;
|
||||
if (!api.hasPrivilege('users:view') &&
|
||||
!api.isLoggedIn({name: userName})) {
|
||||
this._view = new EmptyView();
|
||||
this._view.showError('You don\'t have privileges to view users.');
|
||||
return;
|
||||
}
|
||||
|
||||
topNavigation.setTitle('User ' + userName);
|
||||
User.get(userName).then(user => {
|
||||
const isLoggedIn = api.isLoggedIn(user);
|
||||
const infix = isLoggedIn ? 'self' : 'any';
|
||||
|
||||
this._name = ctx.parameters.name;
|
||||
this._name = userName;
|
||||
user.addEventListener('change', e => this._evtSaved(e));
|
||||
|
||||
const myRankIndex = api.user ?
|
||||
|
Reference in New Issue
Block a user