source: Dev/branches/rest-dojo-ui/client/rft/ui/LoginDialog.js @ 274

Last change on this file since 274 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: 1.9 KB
Line 
1define(['dojo/_base/declare','dojo/_base/lang','dojo/_base/event','dijit/Dialog',
2    'dijit/_WidgetsInTemplateMixin','../auth', 'dojo/text!./LoginDialog.html',
3    '../content','dijit/form/Form','dijit/form/Button','dijit/form/TextBox'],
4    function (declare, lang, event, Dialog, _WidgetsInTemplateMixin, auth, template, content) {
5        return declare([Dialog,_WidgetsInTemplateMixin], {
6            templateString: template,
7            widgetsInTemplate: true,
8            title: "Login/Register",
9            baseClass: "rftLoginDialog",
10            startup: function() {
11                this.inherited(arguments);
12                this.loginForm.on('submit',lang.hitch(this,'onLogin'));
13            },
14            show: function() {
15                this.loginErrors.innerHTML = '';
16                this.loginForm.reset();
17                this.inherited(arguments);
18            },
19            onLogin: function(evt) {
20                this.loginErrors.innerHTML = '';
21                var data = this.loginForm.get('value');
22                auth.login(data.email,data.password)
23                .then(lang.hitch(this,function() {
24                    this.hide();
25                    content.initial();
26                }),lang.hitch(this,function() {
27                    this.loginErrors.innerHTML = 'Login failed.';
28                }));
29                event.stop(evt);
30                return false;
31            },
32            onRegister: function() {
33                this.loginErrors.innerHTML = '';
34                var data = this.loginForm.get('value');
35                auth.register(data.email,data.password)
36                .then(lang.hitch(this,function() {
37                    this.hide();
38                    content.initial();
39                }),lang.hitch(this,function() {
40                    this.loginErrors.innerHTML = 'Register failed.';
41                }));
42            }
43        });
44    });
Note: See TracBrowser for help on using the repository browser.