Pman.Dialog.Login.bjs
[Pman.BAdmin] / Pman.Dialog.Login.js
1 //<script type="text/javascript">
2
3 // Auto generated file - created by app.Builder.js- do not edit directly (at present!)
4
5 Roo.namespace('Pman.Dialog');
6
7 Pman.Dialog.Login= function() {}
8 Roo.apply(Pman.Dialog.Login.prototype, {
9
10  _strings : {
11   'e50b62fb8271673bacc2cfd9d80fbe7a' :"Login to the Management Portal",
12   '99dea78007133396a7b8ed70578ac6ae' :"Login",
13   'cfcd208495d565ef66e7dff9f98764da' :"0",
14   'cd4bcecae78474ea24c3f28350758a8c' :"Forgot your password ?",
15   'dc647eb65e6711e155375218212b3964' :"Password",
16   '06cf692a8d2bb0ab8318dc6c839ae931' :"Two-Factor Authentication Number (if relevant)",
17   '11163ed17ad9afc7680bb9e92f15d6fd' :"We have sent you a link to reset your password",
18   '5047040b025ce0295b58d42250014417' :"<div id=\"login-err\" class=\"dialog-err\" style=\"color:red\"></div>",
19   '24efa7ee4511563b16144f39706d594f' :"Notice",
20   '643a860f992333b8600ea264aca7c4fc' :"Email Address"
21  },
22  _named_strings : {
23   'username_placeholder' : '643a860f992333b8600ea264aca7c4fc' /* Email Address */ ,
24   '_force_value' : 'cfcd208495d565ef66e7dff9f98764da' /* 0 */ ,
25   'password_placeholder' : 'dc647eb65e6711e155375218212b3964' /* Password */ ,
26   'oath_password_placeholder' : '06cf692a8d2bb0ab8318dc6c839ae931' /* Two-Factor Authentication Number (if relevant) */ ,
27   'OK_html' : '99dea78007133396a7b8ed70578ac6ae' /* Login */ 
28  },
29
30  dialog : false,
31  callback:  false,
32
33  show : function(data, cb)
34  {
35   if (!this.dialog) {
36    this.create();
37   }
38
39   this.callback = cb;
40   this.data = data;
41   this.dialog.show(this.data._el);
42   if (this.form) {
43    this.form.reset();
44    this.form.setValues(data);
45    this.form.fireEvent('actioncomplete', this.form,  { type: 'setdata', data: data });
46   }
47
48  },
49
50  create : function()
51  {
52   var _this = this;
53   this.dialog = Roo.factory({
54     xtype : 'Modal',
55     allow_close : false,
56     buttonPosition : 'center',
57     cls : 'enable-overflow login-dialog padding-bottom-trim',
58     _dialog_title_login : _this._strings['e50b62fb8271673bacc2cfd9d80fbe7a'] /* Login to the Management Portal */,
59     listeners : {
60      btnclick : function (e)
61       {
62           if(e == 'cancel'){
63               _this.dialog.hide();
64               return;
65           }
66           
67           _this.dialog.el.select('.modal-content', true).first().mask('Sending...');
68           _this.form.doAction('submit');
69       },
70      render : function (_self) {
71       
72           Roo.get('login-err').dom.innerHTML = "";
73           _this.dialog.el.select('.modal-content', true).first().unmask();
74           
75           if(Roo.isTouch){
76               this.animate = false;
77           }
78       },
79      show : function (_self)
80       {
81           this.setTitle( _this.dialog._dialog_title_login );
82           
83           if (!Roo.state.Manager.getProvider().expires) {
84               Roo.state.Manager.setProvider(new Roo.state.CookieProvider());
85           }
86           
87           _this.lastLogin = Roo.state.Manager.get('Pman.Login', {});
88           _this.form.findField('username').focus();
89       }
90     },
91     xns : Roo.bootstrap,
92     '|xns' : 'Roo.bootstrap',
93     buttons : [
94      {
95       xtype : 'Button',
96       html : _this._strings['99dea78007133396a7b8ed70578ac6ae'] /* Login */,
97       name : 'OK',
98       style : 'float: right',
99       weight : 'primary',
100       xns : Roo.bootstrap,
101       '|xns' : 'Roo.bootstrap'
102      },
103      {
104       xtype : 'Button',
105       _forgot_passwd_success_body : _this._strings['11163ed17ad9afc7680bb9e92f15d6fd'] /* We have sent you a link to reset your password */,
106       _forgot_passwd_success_title : _this._strings['24efa7ee4511563b16144f39706d594f'] /* Notice */,
107       href : '#',
108       html : _this._strings['cd4bcecae78474ea24c3f28350758a8c'] /* Forgot your password ? */,
109       removeClass : true,
110       style : 'float: left',
111       tag : 'a',
112       weight : 'link',
113       listeners : {
114        click : function () {
115         
116             _this.dialog.hide();
117             
118             var email = _this.form.findField('username').getValue();
119             
120             var _self = this;
121             
122             Pman.Dialog.BAdminForgotPassword.show({email : email}, function(){
123                 Roo.bootstrap.MessageBox.alert(_self._forgot_passwd_success_title, _self._forgot_passwd_success_body, function() {
124                         _this.dialog.show();
125                 });
126         
127             });
128         }
129       },
130       xns : Roo.bootstrap,
131       '|xns' : 'Roo.bootstrap'
132      }
133     ],
134     items  : [
135      {
136       xtype : 'Row',
137       listeners : {
138        render : function (_self)
139         {
140             _this.login = this;
141             
142             this.el.setVisibilityMode(Roo.Element.DISPLAY);
143         }
144       },
145       xns : Roo.bootstrap,
146       '|xns' : 'Roo.bootstrap',
147       items  : [
148        {
149         xtype : 'Column',
150         xs : 12,
151         xns : Roo.bootstrap,
152         '|xns' : 'Roo.bootstrap',
153         items  : [
154          {
155           xtype : 'Row',
156           xns : Roo.bootstrap,
157           '|xns' : 'Roo.bootstrap',
158           items  : [
159            {
160             xtype : 'Container',
161             cls : 'col-md-12',
162             xns : Roo.bootstrap,
163             '|xns' : 'Roo.bootstrap',
164             items  : [
165              {
166               xtype : 'Form',
167               labelAlign : 'left',
168               loadMask : false,
169               method : 'POST',
170               url : baseURL + '/Login',
171               listeners : {
172                actioncomplete : function (_self, action) {
173                     
174                     if(action.type == 'setdata'){
175                 
176                         if(
177                             _this.lastLogin && 
178                             _this.lastLogin.login_provider == ''
179                         ){
180                             _this.form.findField('username').setValue(_this.lastLogin.email);
181                         }
182                         
183                         Roo.get('login-err').dom.innerHTML = "";
184                         _this.errorRow.hide();
185                         _this.dialog.el.select('.modal-content', true).first().unmask();
186                         this.clearInvalid();
187                         return;
188                     }
189                      
190                     if(action.type == 'load'){
191                         
192                         return;
193                     }
194                     
195                     if (action.type =='submit') {
196                     
197                         _this.dialog.hide();
198                         
199                         var cb = function(){
200                             if (_this.callback) {
201                                 _this.callback.call(_this, action.result);
202                             }
203                             
204                             _this.form.reset();
205                             
206                             return;
207                         }
208                         
209                         if(
210                             !action.result.data.oath_key_enable &&
211                             action.result.data.require_oath * 1 == 1
212                         ) {
213                             Roo.bootstrap.MessageBox.show({
214                                 title : "Two Factor Authentication is required",
215                                 closable : false,
216                                 msg : "This system requires that you use Google Two Factor Authentication.",
217                                 buttons : {yes:'Setup Two Factor Authentication'},
218                                 fn : function(ret){
219                                     if(ret != 'yes'){
220                                          return;
221                                      }
222                                     
223                                     Pman.Dialog.BAdminStaffTwoFactorQRCode.show(
224                                         {id: action.result.data.id, allow_close : true },
225                                         cb
226                                     )
227                                 }
228                             });
229                             
230                             return;
231                         }
232                         
233                         cb();
234                     }
235                 },
236                actionfailed : function (_self, action) {
237                     Roo.log('action failed?!');
238                     Roo.log(action);
239                     
240                     _this.dialog.el.select('.modal-content', true).first().unmask();
241                     
242                     if (typeof(action) != 'undefined' && action.failureType == 'server') {
243                         
244                         switch (action.result.errorMsg) {
245                                     
246                             case 'Authenticated' :
247                                 
248                                 var data = Roo.apply(action.result.errors);
249                                 
250                                 data.target = _this.form.findField('username').getValue();
251                                 
252                                 Roo.bootstrap.MessageBox.alert("Error", "odd error messages");
253                                 
254                                 break;
255                                 
256                             case 'NEW-IP-ADDRESS' :
257                             case 'PENDING-IP-ADDRESS' :
258                             case 'BAD-IP-ADDRESS' :
259                             case 'BLOCKED-IP-ADDRESS' :
260                                 
261                                 _this.dialog.hide();
262                                 
263                                 Pman.Dialog.LoginNotice.show({
264                                     status : action.result.errorMsg,
265                                     ip : action.result.errors.ip
266                                 });
267                                 
268                                 break;
269                                 
270                             default:
271                                _this.errorRow.show();
272                                 Roo.get('login-err').dom.innerHTML = action.result.errorMsg;
273                                 break;
274                         }
275                         
276                         return;
277                     }
278                     
279                     Roo.get('login-err').dom.innerHTML = "Fill in all the required fields";
280                 },
281                render : function (_self) {
282                     _this.form = _self;
283                 }
284               },
285               xns : Roo.bootstrap,
286               '|xns' : 'Roo.bootstrap',
287               items  : [
288                {
289                 xtype : 'Container',
290                 cls : 'col-sm-12',
291                 xns : Roo.bootstrap,
292                 '|xns' : 'Roo.bootstrap',
293                 items  : [
294                  {
295                   xtype : 'Input',
296                   allowBlank : false,
297                   inputType : 'email',
298                   name : 'username',
299                   placeholder : _this._strings['643a860f992333b8600ea264aca7c4fc'] /* Email Address */,
300                   vtype : 'email',
301                   listeners : {
302                    specialkey : function (_self, e)
303                     {
304                         if(e.getKey() == 13){
305                             _this.dialog.el.select('.modal-content', true).first().mask('Sending...');
306                             _this.form.doAction('submit');
307                         }
308                         
309                     }
310                   },
311                   xns : Roo.bootstrap,
312                   '|xns' : 'Roo.bootstrap'
313                  },
314                  {
315                   xtype : 'Input',
316                   allowBlank : false,
317                   inputType : 'password',
318                   name : 'password',
319                   placeholder : _this._strings['dc647eb65e6711e155375218212b3964'] /* Password */,
320                   listeners : {
321                    specialkey : function (_self, e)
322                     {
323                         if(e.getKey() == 13){
324                             _this.dialog.el.select('.modal-content', true).first().mask('Sending...');
325                             _this.form.doAction('submit');
326                         }
327                     }
328                   },
329                   xns : Roo.bootstrap,
330                   '|xns' : 'Roo.bootstrap'
331                  },
332                  {
333                   xtype : 'NumberField',
334                   allowBlank : true,
335                   allowDecimals : false,
336                   allowNegative : false,
337                   allowZero : true,
338                   decimalPrecision : 0,
339                   maxLength : 6,
340                   name : 'oath_password',
341                   placeholder : _this._strings['06cf692a8d2bb0ab8318dc6c839ae931'] /* Two-Factor Authentication Number (if relevant) */,
342                   listeners : {
343                    specialkey : function (_self, e)
344                     {
345                         if(e.getKey() == 13){
346                             _this.dialog.el.select('.modal-content', true).first().mask('Sending...');
347                             _this.form.doAction('submit');
348                         }
349                     }
350                   },
351                   xns : Roo.bootstrap,
352                   '|xns' : 'Roo.bootstrap'
353                  },
354                  {
355                   xtype : 'Input',
356                   inputType : 'hidden',
357                   name : '_force',
358                   value : 0,
359                   xns : Roo.bootstrap,
360                   '|xns' : 'Roo.bootstrap'
361                  }
362                 ]
363                }
364               ]
365              }
366             ]
367            }
368           ]
369          },
370          {
371           xtype : 'Row',
372           listeners : {
373            render : function (_self)
374             {
375                 _this.errorRow = this;
376             }
377           },
378           xns : Roo.bootstrap,
379           '|xns' : 'Roo.bootstrap',
380           items  : [
381            {
382             xtype : 'Container',
383             cls : 'col-md-12',
384             xns : Roo.bootstrap,
385             '|xns' : 'Roo.bootstrap',
386             items  : [
387              {
388               xtype : 'Container',
389               cls : 'bg-danger',
390               html : _this._strings['5047040b025ce0295b58d42250014417'] /* <div id="login-err" class="dialog-err" style="color:red"></div> */,
391               style : 'margin-bottom: 15px;\n    padding: 5px;',
392               xns : Roo.bootstrap,
393               '|xns' : 'Roo.bootstrap'
394              }
395             ]
396            }
397           ]
398          }
399         ]
400        }
401       ]
402      }
403     ]
404    }  );
405  }
406 });
407 Roo.apply(Pman.Dialog.Login, Pman.Dialog.Login.prototype);