szurubooru/static/js/controllers/auth_controller.js

41 lines
847 B
JavaScript
Raw Normal View History

'use strict';
class AuthController {
2016-03-28 00:19:44 +02:00
constructor(topNavigationController, loginView) {
this.topNavigationController = topNavigationController;
2016-03-28 00:19:44 +02:00
this.loginView = loginView;
this.currentUser = null;
}
isLoggedIn() {
return this.currentUser !== null;
}
hasPrivilege() {
return true;
}
login(user) {
this.currentUser = user;
}
logout(user) {
this.currentUser = null;
}
loginRoute() {
this.topNavigationController.activate('login');
2016-03-28 00:19:44 +02:00
this.loginView.render({
login: (user, password) => {
alert(user, password);
//self.authController.login(user);
}});
}
logoutRoute() {
this.topNavigationController.activate('logout');
}
}
module.exports = AuthController;