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