Last change
on this file since 263 was
260,
checked in by hendrikvanantwerpen, 13 years ago
|
- Clear LoginDialog? on show (in case of re-show).
- Allow to link nodes/widgets to rft.ui.Page members with data-rft-attach-point attribute.
- Allow arguments to a page to be passed with data-rft-props argument. Content loader rft.content sets this argument on the top node of a loaded page.
- Have longer cookie-lifetime and update cookie when session is restored. Allow session restore in API and client code.
- Moved startup Javascript to rft/run.js.
|
File size:
2.0 KB
|
Rev | Line | |
---|
[260] | 1 | define(['dojo/_base/Deferred','dojo/_base/xhr','dojo/_base/json'], |
---|
| 2 | function(Deferred,xhr,json){ |
---|
| 3 | return new (function() { |
---|
| 4 | var self = this; |
---|
| 5 | var currentUser = null; |
---|
[256] | 6 | |
---|
[260] | 7 | function post(path,args) { |
---|
| 8 | return xhr.post({ |
---|
| 9 | url: "../server/api.php"+path, |
---|
| 10 | handleAs: "json", |
---|
| 11 | headers: { |
---|
| 12 | "Content-Type": "application/json" |
---|
| 13 | }, |
---|
| 14 | rawBody: json.toJson(args) |
---|
| 15 | }); |
---|
| 16 | } |
---|
| 17 | |
---|
| 18 | self.login = function(username,password) { |
---|
| 19 | var d = new Deferred(); |
---|
| 20 | post("/login", |
---|
| 21 | { |
---|
| 22 | username:username, |
---|
| 23 | password:password |
---|
| 24 | }) |
---|
| 25 | .then(function(data) { |
---|
| 26 | currentUser = data; |
---|
| 27 | d.resolve(data); |
---|
| 28 | },function(){ |
---|
| 29 | d.reject(); |
---|
| 30 | }); |
---|
| 31 | return d.promise; |
---|
| 32 | }; |
---|
| 33 | |
---|
| 34 | self.restore = function() { |
---|
| 35 | var d = new Deferred(); |
---|
| 36 | post("/login",{}) |
---|
| 37 | .then(function(data) { |
---|
| 38 | currentUser = data; |
---|
| 39 | d.resolve(data); |
---|
| 40 | },function(){ |
---|
| 41 | d.reject(); |
---|
| 42 | }); |
---|
| 43 | return d.promise; |
---|
[256] | 44 | |
---|
[260] | 45 | }; |
---|
| 46 | |
---|
| 47 | self.register = function(username,password) { |
---|
| 48 | var d = new Deferred(); |
---|
| 49 | post("/register", |
---|
| 50 | { |
---|
| 51 | username:username, |
---|
| 52 | password:password |
---|
| 53 | }) |
---|
| 54 | .then(function(data) { |
---|
| 55 | currentUser = data; |
---|
| 56 | d.resolve(data); |
---|
| 57 | },function(){ |
---|
| 58 | d.reject(); |
---|
| 59 | }); |
---|
| 60 | return d.promise; |
---|
| 61 | }; |
---|
[256] | 62 | |
---|
[260] | 63 | self.getUser = function(){ |
---|
| 64 | return currentUser; |
---|
| 65 | }; |
---|
| 66 | })(); |
---|
| 67 | }); |
---|
Note: See
TracBrowser
for help on using the repository browser.