application/js/user.js in spontaneous-0.2.0.alpha2 vs application/js/user.js in spontaneous-0.2.0.alpha3
- old
+ new
@@ -1,8 +1,10 @@
// console.log('Loading User...')
Spontaneous.User = (function($, S) {
+ var ajax = S.Ajax;
+
var User = new JS.Class({
initialize: function(user_data) {
this.attrs = user_data;
},
name: function() {
@@ -14,24 +16,36 @@
login: function() {
return this.attrs.login;
},
is_developer: function() {
return this.attrs.developer;
+ },
+ is_admin: function() {
+ return this.attrs.admin;
+ },
+ can_publish: function() {
+ return this.attrs.can_publish;
}
});
var instance = new JS.Singleton({
include: Spontaneous.Properties,
- load: function() {
- S.Ajax.get('/user', this.loaded.bind(this));
- },
+
loaded: function(user_data) {
this.user = new User(user_data);
this.set('user', this.user);
},
+ logout: function() {
+ ajax.post("/logout", {}, function() {
+ // S.Ajax.unauthorized();
+ });
+ S.Auth.Key.remove(S.site_id);
+ },
name: function() { return this.user.name(); },
email: function() { return this.user.email(); },
login: function() { return this.user.login(); },
- is_developer: function() { return this.user.is_developer(); }
+ is_developer: function() { return this.user.is_developer(); },
+ is_admin: function() { return this.user.is_admin(); },
+ can_publish: function() { return this.user.can_publish(); }
});
return instance;
}(jQuery, Spontaneous));