mirror of
https://github.com/rr-/szurubooru.git
synced 2025-07-17 08:26:24 +00:00
Refactored frontend authentication system
This commit is contained in:
@ -7,7 +7,6 @@ App.Presenters.LoginPresenter = function(
|
||||
promise,
|
||||
router,
|
||||
auth,
|
||||
appState,
|
||||
topNavigationPresenter,
|
||||
messagePresenter) {
|
||||
|
||||
@ -19,7 +18,7 @@ App.Presenters.LoginPresenter = function(
|
||||
topNavigationPresenter.select('login');
|
||||
promise.wait(util.promiseTemplate('login-form')).then(function(html) {
|
||||
template = _.template(html);
|
||||
if (appState.get('loggedIn'))
|
||||
if (auth.isLoggedIn())
|
||||
router.navigateToMainPage();
|
||||
else
|
||||
render();
|
||||
|
@ -5,7 +5,7 @@ App.Presenters.TopNavigationPresenter = function(
|
||||
jQuery,
|
||||
util,
|
||||
promise,
|
||||
appState) {
|
||||
auth) {
|
||||
|
||||
var selectedElement = null;
|
||||
var $el = jQuery('#top-navigation');
|
||||
@ -15,7 +15,7 @@ App.Presenters.TopNavigationPresenter = function(
|
||||
promise.wait(util.promiseTemplate('top-navigation')).then(function(html) {
|
||||
template = _.template(html);
|
||||
render();
|
||||
appState.startObserving('loggedIn', 'top-navigation', loginStateChanged);
|
||||
auth.startObservingLoginChanges('top-navigation', loginStateChanged);
|
||||
});
|
||||
}
|
||||
|
||||
@ -31,9 +31,9 @@ App.Presenters.TopNavigationPresenter = function(
|
||||
|
||||
function render() {
|
||||
$el.html(template({
|
||||
loggedIn: appState.get('loggedIn'),
|
||||
user: appState.get('loggedInUser'),
|
||||
privileges: appState.get('privileges'),
|
||||
loggedIn: auth.isLoggedIn(),
|
||||
user: auth.getCurrentUser(),
|
||||
canListUsers: auth.hasPrivilege('listUsers')
|
||||
}));
|
||||
$el.find('li.' + selectedElement).addClass('active');
|
||||
};
|
||||
|
@ -6,7 +6,7 @@ App.Presenters.UserPresenter = function(
|
||||
util,
|
||||
promise,
|
||||
api,
|
||||
appState,
|
||||
auth,
|
||||
topNavigationPresenter,
|
||||
messagePresenter) {
|
||||
|
||||
@ -20,7 +20,7 @@ App.Presenters.UserPresenter = function(
|
||||
|
||||
function init(args) {
|
||||
userName = args.userName;
|
||||
topNavigationPresenter.select(appState.get('loggedIn') && appState.get('loggedInUser').name == userName ? 'my-account' : 'users');
|
||||
topNavigationPresenter.select(auth.isLoggedIn() && auth.getCurrentUser().name == userName ? 'my-account' : 'users');
|
||||
|
||||
promise.waitAll(
|
||||
util.promiseTemplate('user'),
|
||||
|
Reference in New Issue
Block a user