mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-16 23:30:23 +00:00
36 lines
816 B
JavaScript
36 lines
816 B
JavaScript
// Copyright (C) 2008,2009 BRAT Tech LLC
|
|
nglr.Users = function(server, controlBar) {
|
|
this.server = server;
|
|
this.controlBar = controlBar;
|
|
};
|
|
|
|
nglr.Users.prototype = {
|
|
fetchCurrentUser:function(callback) {
|
|
var self = this;
|
|
this.server.request("GET", "/account.json", {}, function(code, response){
|
|
self.current = response.user;
|
|
callback(response.user);
|
|
});
|
|
},
|
|
|
|
logout: function(callback) {
|
|
var self = this;
|
|
this.controlBar.logout(function(){
|
|
delete self.current;
|
|
(callback||nglr.noop)();
|
|
});
|
|
},
|
|
|
|
login: function(callback) {
|
|
var self = this;
|
|
this.controlBar.login(function(){
|
|
self.fetchCurrentUser(function(){
|
|
(callback||nglr.noop)();
|
|
});
|
|
});
|
|
},
|
|
|
|
notAuthorized: function(){
|
|
this.controlBar.notAuthorized();
|
|
}
|
|
};
|