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