Last change
on this file since 335 was
274,
checked in by hendrikvanantwerpen, 13 years ago
|
- [Client] Moved pages in subtree of rft/, allowing controllers next to them.
- [Client] Created questions page, gives overview and allows adding.
- [Client] Page controllers inherit from _Page, because the previous mechanism w
asn't working.
- [Client] Added new user registration.
- [Server] Changed user passwords to passwordHash/passwordSalt combination.
- [Server] Added simple object marshalling and unmarshalling to preserve types.
- [Server] Added ResearchToolObjectInterface? with static create() method. Implemented for all model classes.
|
File size:
2.0 KB
|
Line | |
---|
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; |
---|
6 | |
---|
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 | email: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; |
---|
44 | |
---|
45 | }; |
---|
46 | |
---|
47 | self.register = function(username,password) { |
---|
48 | var d = new Deferred(); |
---|
49 | post("/register", |
---|
50 | { |
---|
51 | email: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 | }; |
---|
62 | |
---|
63 | self.getUser = function(){ |
---|
64 | return currentUser; |
---|
65 | }; |
---|
66 | })(); |
---|
67 | }); |
---|
Note: See
TracBrowser
for help on using the repository browser.