mirror of
https://github.com/rr-/szurubooru.git
synced 2025-07-17 08:26:24 +00:00
server/users: let administrators add new users
* Added functionality for administrators to directly add users to the application * Added permission users:create:any to handle level that users are allowed to create other users * Moved old permission users:create to users:create:self
This commit is contained in:
@ -47,10 +47,12 @@ class TopNavigationController {
|
||||
topNavigation.hide('users');
|
||||
}
|
||||
if (api.isLoggedIn()) {
|
||||
topNavigation.hide('register');
|
||||
if (!api.hasPrivilege('users:create:any')) {
|
||||
topNavigation.hide('register');
|
||||
}
|
||||
topNavigation.hide('login');
|
||||
} else {
|
||||
if (!api.hasPrivilege('users:create')) {
|
||||
if (!api.hasPrivilege('users:create:self')) {
|
||||
topNavigation.hide('register');
|
||||
}
|
||||
topNavigation.hide('account');
|
||||
|
@ -10,7 +10,7 @@ const EmptyView = require('../views/empty_view.js');
|
||||
|
||||
class UserRegistrationController {
|
||||
constructor() {
|
||||
if (!api.hasPrivilege('users:create')) {
|
||||
if (!api.hasPrivilege('users:create:self')) {
|
||||
this._view = new EmptyView();
|
||||
this._view.showError('Registration is closed.');
|
||||
return;
|
||||
@ -29,12 +29,22 @@ class UserRegistrationController {
|
||||
user.name = e.detail.name;
|
||||
user.email = e.detail.email;
|
||||
user.password = e.detail.password;
|
||||
const isLoggedIn = api.isLoggedIn();
|
||||
user.save().then(() => {
|
||||
api.forget();
|
||||
return api.login(e.detail.name, e.detail.password, false);
|
||||
if (isLoggedIn) {
|
||||
return Promise.resolve();
|
||||
} else {
|
||||
api.forget();
|
||||
return api.login(e.detail.name, e.detail.password, false);
|
||||
}
|
||||
}).then(() => {
|
||||
const ctx = router.show(uri.formatClientLink());
|
||||
ctx.controller.showSuccess('Welcome aboard!');
|
||||
if (isLoggedIn) {
|
||||
const ctx = router.show(uri.formatClientLink('users'));
|
||||
ctx.controller.showSuccess('User added!');
|
||||
} else {
|
||||
const ctx = router.show(uri.formatClientLink());
|
||||
ctx.controller.showSuccess('Welcome aboard!');
|
||||
}
|
||||
}, error => {
|
||||
this._view.showError(error.message);
|
||||
this._view.enableForm();
|
||||
|
Reference in New Issue
Block a user