old version of group mgr got merged
[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       cls : 'login-forgot-pass-btn',
106       _forgot_passwd_success_body : _this._strings['11163ed17ad9afc7680bb9e92f15d6fd'] /* We have sent you a link to reset your password */,
107       _forgot_passwd_success_title : _this._strings['24efa7ee4511563b16144f39706d594f'] /* Notice */,
108       href : '#',
109       html : _this._strings['cd4bcecae78474ea24c3f28350758a8c'] /* Forgot your password ? */,
110       removeClass : true,
111       style : 'float: left',
112       tag : 'a',
113       weight : 'link',
114       listeners : {
115        click : function () {
116         
117             _this.dialog.hide();
118             
119             var email = _this.form.findField('username').getValue();
120             
121             var _self = this;
122             
123             Pman.Dialog.BAdminForgotPassword.show({email : email}, function(){
124                 Roo.bootstrap.MessageBox.alert(_self._forgot_passwd_success_title, _self._forgot_passwd_success_body, function() {
125                         _this.dialog.show();
126                 });
127         
128             });
129         }
130       },
131       xns : Roo.bootstrap,
132       '|xns' : 'Roo.bootstrap'
133      }
134     ],
135     items  : [
136      {
137       xtype : 'Row',
138       listeners : {
139        render : function (_self)
140         {
141             _this.login = this;
142             
143             this.el.setVisibilityMode(Roo.Element.DISPLAY);
144         }
145       },
146       xns : Roo.bootstrap,
147       '|xns' : 'Roo.bootstrap',
148       items  : [
149        {
150         xtype : 'Column',
151         xs : 12,
152         xns : Roo.bootstrap,
153         '|xns' : 'Roo.bootstrap',
154         items  : [
155          {
156           xtype : 'Row',
157           xns : Roo.bootstrap,
158           '|xns' : 'Roo.bootstrap',
159           items  : [
160            {
161             xtype : 'Container',
162             cls : 'col-md-12',
163             xns : Roo.bootstrap,
164             '|xns' : 'Roo.bootstrap',
165             items  : [
166              {
167               xtype : 'Form',
168               labelAlign : 'left',
169               loadMask : false,
170               method : 'POST',
171               url : baseURL + '/Login',
172               listeners : {
173                actioncomplete : function (_self, action) {
174                     
175                     if(action.type == 'setdata'){
176                 
177                         if(
178                             _this.lastLogin && 
179                             _this.lastLogin.login_provider == ''
180                         ){
181                             _this.form.findField('username').setValue(_this.lastLogin.email);
182                         }
183                         
184                         Roo.get('login-err').dom.innerHTML = "";
185                         _this.errorRow.hide();
186                         _this.dialog.el.select('.modal-content', true).first().unmask();
187                         this.clearInvalid();
188                         return;
189                     }
190                      
191                     if(action.type == 'load'){
192                         
193                         return;
194                     }
195                     
196                     if (action.type =='submit') {
197                     
198                         _this.dialog.hide();
199                         
200                         var cb = function(){
201                             if (_this.callback) {
202                                 _this.callback.call(_this, action.result);
203                             }
204                             
205                             _this.form.reset();
206                             
207                             return;
208                         }
209                         
210                         if(
211                             !action.result.data.oath_key_enable &&
212                             action.result.data.require_oath * 1 == 1
213                         ) {
214                             Roo.bootstrap.MessageBox.show({
215                                 title : "Two Factor Authentication is required",
216                                 closable : false,
217                                 msg : "This system requires that you use Google Two Factor Authentication.",
218                                 buttons : {yes:'Setup Two Factor Authentication'},
219                                 fn : function(ret){
220                                     if(ret != 'yes'){
221                                          return;
222                                      }
223                                     
224                                     Pman.Dialog.BAdminStaffTwoFactorQRCode.show(
225                                         {id: action.result.data.id, allow_close : true },
226                                         cb
227                                     );
228                                 }
229                             });
230                             
231                             return;
232                         }
233                         
234                         cb();
235                     }
236                 },
237                actionfailed : function (_self, action) {
238                     Roo.log('action failed?!');
239                     Roo.log(action);
240                     
241                     _this.dialog.el.select('.modal-content', true).first().unmask();
242                     
243                     if (typeof(action) != 'undefined' && action.failureType == 'server') {
244                         
245                         switch (action.result.errorMsg) {
246                                     
247                             case 'Authenticated' :
248                                 
249                                 var data = Roo.apply(action.result.errors);
250                                 
251                                 data.target = _this.form.findField('username').getValue();
252                                 
253                                 Roo.bootstrap.MessageBox.alert("Error", "odd error messages");
254                                 
255                                 break;
256                                 
257                             case 'NEW-IP-ADDRESS' :
258                             case 'PENDING-IP-ADDRESS' :
259                             case 'BAD-IP-ADDRESS' :
260                             case 'BLOCKED-IP-ADDRESS' :
261                                 
262                                 _this.dialog.hide();
263                                 
264                                 Pman.Dialog.LoginNotice.show({
265                                     status : action.result.errorMsg,
266                                     ip : action.result.errors.ip
267                                 });
268                                 
269                                 break;
270                                 
271                             default:
272                                _this.errorRow.show();
273                                 Roo.get('login-err').dom.innerHTML = action.result.errorMsg;
274                                 break;
275                         }
276                         
277                         return;
278                     }
279                     
280                     Roo.get('login-err').dom.innerHTML = "Fill in all the required fields";
281                 },
282                render : function (_self) {
283                     _this.form = _self;
284                 }
285               },
286               xns : Roo.bootstrap,
287               '|xns' : 'Roo.bootstrap',
288               items  : [
289                {
290                 xtype : 'Container',
291                 cls : 'col-sm-12',
292                 xns : Roo.bootstrap,
293                 '|xns' : 'Roo.bootstrap',
294                 items  : [
295                  {
296                   xtype : 'Input',
297                   allowBlank : false,
298                   inputType : 'email',
299                   name : 'username',
300                   placeholder : _this._strings['643a860f992333b8600ea264aca7c4fc'] /* Email Address */,
301                   vtype : 'email',
302                   listeners : {
303                    specialkey : function (_self, e)
304                     {
305                         if(e.getKey() == 13){
306                             _this.dialog.el.select('.modal-content', true).first().mask('Sending...');
307                             _this.form.doAction('submit');
308                         }
309                         
310                     }
311                   },
312                   xns : Roo.bootstrap,
313                   '|xns' : 'Roo.bootstrap'
314                  },
315                  {
316                   xtype : 'Input',
317                   allowBlank : false,
318                   inputType : 'password',
319                   name : 'password',
320                   placeholder : _this._strings['dc647eb65e6711e155375218212b3964'] /* Password */,
321                   listeners : {
322                    specialkey : function (_self, e)
323                     {
324                         if(e.getKey() == 13){
325                             _this.dialog.el.select('.modal-content', true).first().mask('Sending...');
326                             _this.form.doAction('submit');
327                         }
328                     }
329                   },
330                   xns : Roo.bootstrap,
331                   '|xns' : 'Roo.bootstrap'
332                  },
333                  {
334                   xtype : 'NumberField',
335                   allowBlank : true,
336                   allowDecimals : false,
337                   allowNegative : false,
338                   allowZero : true,
339                   decimalPrecision : 0,
340                   maxLength : 6,
341                   name : 'oath_password',
342                   placeholder : _this._strings['06cf692a8d2bb0ab8318dc6c839ae931'] /* Two-Factor Authentication Number (if relevant) */,
343                   listeners : {
344                    specialkey : function (_self, e)
345                     {
346                         if(e.getKey() == 13){
347                             _this.dialog.el.select('.modal-content', true).first().mask('Sending...');
348                             _this.form.doAction('submit');
349                         }
350                     }
351                   },
352                   xns : Roo.bootstrap,
353                   '|xns' : 'Roo.bootstrap'
354                  },
355                  {
356                   xtype : 'Input',
357                   inputType : 'hidden',
358                   name : '_force',
359                   value : 0,
360                   xns : Roo.bootstrap,
361                   '|xns' : 'Roo.bootstrap'
362                  }
363                 ]
364                }
365               ]
366              }
367             ]
368            }
369           ]
370          },
371          {
372           xtype : 'Row',
373           listeners : {
374            render : function (_self)
375             {
376                 _this.errorRow = this;
377             }
378           },
379           xns : Roo.bootstrap,
380           '|xns' : 'Roo.bootstrap',
381           items  : [
382            {
383             xtype : 'Container',
384             cls : 'col-md-12',
385             xns : Roo.bootstrap,
386             '|xns' : 'Roo.bootstrap',
387             items  : [
388              {
389               xtype : 'Container',
390               cls : 'bg-danger',
391               html : _this._strings['5047040b025ce0295b58d42250014417'] /* <div id="login-err" class="dialog-err" style="color:red"></div> */,
392               style : 'margin-bottom: 15px;\n    padding: 5px;',
393               xns : Roo.bootstrap,
394               '|xns' : 'Roo.bootstrap'
395              }
396             ]
397            }
398           ]
399          }
400         ]
401        }
402       ]
403      }
404     ]
405    }  );
406  }
407 });
408 Roo.apply(Pman.Dialog.Login, Pman.Dialog.Login.prototype);