constructor : function ( kwargs ) {
this.id = kwargs.id;
this.user = kwargs.user;
- this.authtoken = kwargs.authtoken;
- this.authtime = kwargs.authtime;
+ this.passwd = kwargs.passwd;
+ this.authtoken = kwargs.authtoken || openils.User.authtoken;
+ this.authtime = kwargs.authtime || openils.User.authtime;
this.login_type = kwargs.login_type;
this.location = kwargs.location;
- if (this.id && this.authtoken) this.getById();
- else if (this.authtoken) this.getBySession();
+ if (this.authtoken) this.getBySession();
+ else if (this.id && this.authtoken) this.user = this.getById( this.id );
else if (kwargs.login) this.login();
},
req.oncomplete = function(r) {
var user = r.recv().content();
_u.user = user;
+ if (!openils.User.user) !openils.User.user = _u.user;
if(onComplete)
onComplete(user);
}
authReq.oncomplete = function(rr) {
var data = rr.recv().content();
_u.authtoken = data.payload.authtoken;
+ if (!openils.User.authtoken) !openils.User.authtoken = _u.authtoken;
_u.authtime = data.payload.authtime;
+ if (!openils.User.authtime) !openils.User.authtime = _u.authtime;
_u.getBySession(onComplete);
}
authReq.send();
}
});
+
+ openils.User.user = null;
+ openils.User.authtoken = null;
+ openils.User.authtime = null;
+
}