PHP8
[Pman.BAdmin] / Pman.Dialog.BAdminStaffTwoFactorQRCode.bjs
1 {
2  "name" : "Pman.Dialog.BAdminStaffTwoFactorQRCode",
3  "parent" : "",
4  "title" : "",
5  "path" : "/home/edward/gitlive/Pman.BAdmin/Pman.Dialog.BAdminStaffTwoFactorQRCode.bjs",
6  "permname" : "",
7  "modOrder" : "001",
8  "strings" : {
9   "1459eb538ddc78e1908bbd761a444395" : "1. Download an Authentication App on your phone, like \"<a href='#' class='download-google-authenticator' style='color:#337ab7;'>Google Authenticator</a>\" or \"<a href='#' class='download-authy' style='color:#337ab7;'>Authy</a>\" ",
10   "e8e9a5b1083b253b726d1fa7f31176f5" : "2. After adding this to Authenticator app, type in the generated number below to confirm.",
11   "2194867d6c27ce97cd1f0a5db8d5c95e" : "Setup 2-Factor Authentication",
12   "22e960368d2513a40b7467ec143440cc" : "5. After adding this to Authenticator app, type in the generated number below to confirm.",
13   "131e3875e777f6c9a8e510f96a4d20d2" : "Skip for now",
14   "f93dadd0b45b370c51bf80fb0a3eadfa" : "3. For the Account Name user \"{0}\"",
15   "8e5b55264e2acf73fb73b6a327bccd51" : "4. Enter the code below as \"Your Key\"",
16   "4141195b21d661e36e56d91f19d53273" : "2. In the App, select \"<b>Create or Setup an Account</b>\"",
17   "ea4788705e6873b424c65e91c2846b19" : "Cancel",
18   "ee468f72ab7fe4937fb014d6fcea540b" : "Enter Two factor Authentication code",
19   "6d9785b18748c30bb3adbf7506f40202" : "1. Open Authenticator App in your phone, and scan this QR code.",
20   "780573538d031cf7387477f9ea3204f6" : "Copy Key",
21   "70d9be9b139893aa6c69b5e77e614311" : "Confirm"
22  },
23  "named_strings" : {
24   "two_factor_auth_code_fieldLabel" : "ee468f72ab7fe4937fb014d6fcea540b"
25  },
26  "items" : [
27   {
28    "listeners" : {
29     "show" : "function (_self)\n{\n    if(!Pman.Login.authUser) {\n        Roo.bootstrap.MessageBox.alert('Error', 'Please login again');\n        return;\n    }\n    \n    if(\n        !_this.data.id ||\n        _this.data.id.length == 0\n    ) {\n        Roo.bootstrap.MessageBox.alert('Error', 'Please select a person again');\n        return;\n    }\n    \n    _this.dialog.closeEl.hide();\n    _this.skipBtn.hide();\n    _this.cancelBtn.hide();\n    \n    if(_this.data.allow_close) {\n        _this.dialog.closeEl.show();\n        _this.skipBtn.show();\n    }\n    \n    if(_this.data.allow_cancel) {\n        _this.cancelBtn.show();\n    }\n    \n    _this.desktopView.hide();\n    _this.mobileView.hide();\n    \n    new Pman.Request({\n        url: baseURL + '/Roo/Core_person.php',\n        method : 'GET',\n        mask : 'Loading...',\n        params : {\n            _to_qr_code : 1,\n            id: _this.data.id\n        },\n        \n        success : function(res) {\n            _this.qrcode_image.setSrc(res.data.image);\n            _this.secret.setValue(res.data.secret);\n            _this.issuer_notify.el.dom.innerHTML = String.format(_this.issuer_notify._html, res.data.issuer);\n            \n            _this.desktopView.show();\n            _this.mobileView.hide();\n            \n            if(Roo.isTouch) {\n                _this.desktopView.hide();\n                _this.mobileView.show();\n            }\n        },\n        \n        failure : function(res) {\n            Roo.log(res);\n        }\n    });\n}",
30     "hide" : "function (_self)\n{\n    if(_this.callback){\n        _this.callback.call(_this, false);\n    }\n    \n}"
31    },
32    "String cls" : "enable-overflow coba-qr-dialog",
33    "Boolean animate" : false,
34    "Boolean allow_close" : true,
35    "xtype" : "Modal",
36    "$ xns" : "Roo.bootstrap",
37    "String title" : "Setup 2-Factor Authentication",
38    "items" : [
39     {
40      "listeners" : {
41       "render" : "function (_self)\n{\n    _this.skipBtn = this;\n}",
42       "click" : "function (_self, e)\n{\n    _this.dialog.hide();\n    \n    return;\n}"
43      },
44      "String weight" : "default",
45      "xtype" : "Button",
46      "$ xns" : "Roo.bootstrap",
47      "String html" : "Skip for now",
48      "* prop" : "buttons[]"
49     },
50     {
51      "listeners" : {
52       "render" : "function (_self)\n{\n    _this.cancelBtn = this;\n}",
53       "click" : "function (_self, e)\n{\n    _this.dialog.hide();\n    \n    return;\n}"
54      },
55      "String weight" : "default",
56      "xtype" : "Button",
57      "$ xns" : "Roo.bootstrap",
58      "String html" : "Cancel",
59      "* prop" : "buttons[]"
60     },
61     {
62      "listeners" : {
63       "click" : "function (_self, e)\n{\n    _this.form.doAction('submit');\n}"
64      },
65      "String weight" : "primary",
66      "xtype" : "Button",
67      "$ xns" : "Roo.bootstrap",
68      "String html" : "Confirm",
69      "* prop" : "buttons[]"
70     },
71     {
72      "listeners" : {
73       "render" : "function (_self)\n{\n    _this.desktopView = this;\n}"
74      },
75      "xtype" : "Row",
76      "$ xns" : "Roo.bootstrap",
77      "items" : [
78       {
79        "xtype" : "Column",
80        "Number xs" : 12,
81        "$ xns" : "Roo.bootstrap",
82        "items" : [
83         {
84          "xtype" : "Row",
85          "$ xns" : "Roo.bootstrap",
86          "items" : [
87           {
88            "xtype" : "Column",
89            "Number xs" : 12,
90            "$ xns" : "Roo.bootstrap",
91            "items" : [
92             {
93              "xtype" : "Container",
94              "$ xns" : "Roo.bootstrap",
95              "String well" : "sm",
96              "String html" : "1. Open Authenticator App in your phone, and scan this QR code."
97             }
98            ]
99           }
100          ]
101         },
102         {
103          "xtype" : "Row",
104          "$ xns" : "Roo.bootstrap",
105          "items" : [
106           {
107            "String cls" : "text-center",
108            "xtype" : "Column",
109            "Number xs" : 12,
110            "$ xns" : "Roo.bootstrap",
111            "items" : [
112             {
113              "listeners" : {
114               "render" : "function (_self)\n{\n    _this.qrcode_image = this;\n    \n    this.el.setVisibilityMode(Roo.Element.DISPLAY);\n    \n}"
115              },
116              "Boolean imgResponsive" : false,
117              "String cls" : "qr-code",
118              "xtype" : "Img",
119              "String src" : "about:blank",
120              "$ xns" : "Roo.bootstrap"
121             }
122            ]
123           }
124          ]
125         },
126         {
127          "xtype" : "Row",
128          "$ xns" : "Roo.bootstrap",
129          "items" : [
130           {
131            "xtype" : "Column",
132            "Number xs" : 12,
133            "$ xns" : "Roo.bootstrap",
134            "items" : [
135             {
136              "xtype" : "Container",
137              "$ xns" : "Roo.bootstrap",
138              "String well" : "sm",
139              "String html" : "2. After adding this to Authenticator app, type in the generated number below to confirm."
140             }
141            ]
142           }
143          ]
144         }
145        ]
146       }
147      ]
148     },
149     {
150      "listeners" : {
151       "render" : "function (_self)\n{\n    _this.mobileView = this;\n}"
152      },
153      "xtype" : "Row",
154      "$ xns" : "Roo.bootstrap",
155      "items" : [
156       {
157        "xtype" : "Column",
158        "Number xs" : 12,
159        "$ xns" : "Roo.bootstrap",
160        "items" : [
161         {
162          "xtype" : "Row",
163          "$ xns" : "Roo.bootstrap",
164          "items" : [
165           {
166            "xtype" : "Column",
167            "Number xs" : 12,
168            "$ xns" : "Roo.bootstrap",
169            "items" : [
170             {
171              "listeners" : {
172               "render" : "function (_self)\n{\n    this.el.select('.download-google-authenticator', true).first().on('click', function(e){\n        e.preventDefault();\n        \n        if(Roo.isIOS) {\n            window.open(\"https://itunes.apple.com/us/app/google-authenticator/id388497605?mt=8\", \"_blank\");\n            return;\n        }\n        \n        window.open(\"https://play.google.com/store/apps/details?id=com.google.android.apps.authenticator2\", \"_blank\");\n    });\n    \n    this.el.select('.download-authy', true).first().on('click', function(e){\n        e.preventDefault();\n        \n        if(Roo.isIOS) {\n            window.open(\"https://itunes.apple.com/us/app/authy/id494168017?mt=8\", \"_blank\");\n            return;\n        }\n        \n        window.open(\"https://play.google.com/store/apps/details?id=com.ionicpremium.authy\", \"_blank\");\n    });\n}"
173              },
174              "xtype" : "Container",
175              "$ xns" : "Roo.bootstrap",
176              "String well" : "sm",
177              "String html" : "1. Download an Authentication App on your phone, like \"<a href='#' class='download-google-authenticator' style='color:#337ab7;'>Google Authenticator</a>\" or \"<a href='#' class='download-authy' style='color:#337ab7;'>Authy</a>\" "
178             }
179            ]
180           }
181          ]
182         },
183         {
184          "xtype" : "Row",
185          "$ xns" : "Roo.bootstrap",
186          "items" : [
187           {
188            "xtype" : "Column",
189            "Number xs" : 12,
190            "$ xns" : "Roo.bootstrap",
191            "items" : [
192             {
193              "xtype" : "Container",
194              "$ xns" : "Roo.bootstrap",
195              "String well" : "sm",
196              "String html" : "2. In the App, select \"<b>Create or Setup an Account</b>\""
197             }
198            ]
199           }
200          ]
201         },
202         {
203          "xtype" : "Row",
204          "$ xns" : "Roo.bootstrap",
205          "items" : [
206           {
207            "xtype" : "Column",
208            "Number xs" : 12,
209            "$ xns" : "Roo.bootstrap",
210            "items" : [
211             {
212              "listeners" : {
213               "render" : "function (_self)\n{\n    _this.issuer_notify = this;\n}"
214              },
215              "xtype" : "Container",
216              "string _html" : "3. For the Account Name user \"{0}\"",
217              "$ xns" : "Roo.bootstrap",
218              "String well" : "sm",
219              "String html" : "3. For the Account Name user \"{0}\""
220             }
221            ]
222           }
223          ]
224         },
225         {
226          "xtype" : "Row",
227          "$ xns" : "Roo.bootstrap",
228          "items" : [
229           {
230            "xtype" : "Column",
231            "Number xs" : 12,
232            "$ xns" : "Roo.bootstrap",
233            "items" : [
234             {
235              "xtype" : "Container",
236              "$ xns" : "Roo.bootstrap",
237              "String well" : "sm",
238              "String html" : "4. Enter the code below as \"Your Key\""
239             }
240            ]
241           }
242          ]
243         },
244         {
245          "xtype" : "Row",
246          "$ xns" : "Roo.bootstrap",
247          "items" : [
248           {
249            "xtype" : "Column",
250            "Number xs" : 12,
251            "$ xns" : "Roo.bootstrap",
252            "items" : [
253             {
254              "listeners" : {
255               "render" : "function (_self)\n{\n    _this.secret = this;\n}"
256              },
257              "String name" : "secret",
258              "Boolean readOnly" : true,
259              "xtype" : "Input",
260              "$ xns" : "Roo.bootstrap"
261             }
262            ]
263           },
264           {
265            "String cls" : "text-center",
266            "xtype" : "Column",
267            "Number xs" : 12,
268            "$ xns" : "Roo.bootstrap",
269            "items" : [
270             {
271              "listeners" : {
272               "click" : "function (_self, e)\n{\n    var el = _this.secret.inputEl().dom;\n    \n\tif (document.body.createTextRange) {\n\t    // IE\n        var textRange = document.body.createTextRange();\n        textRange.moveToElementText(el);\n        textRange.select();\n        textRange.execCommand(\"Copy\");\n    } else if (window.getSelection && document.createRange) {\n        // Non-IE\n        var editable = el.contentEditable; // Record contentEditable status of element\n        var readOnly = el.readOnly; // Record readOnly status of element\n       \tel.contentEditable = true; // iOS will only select text on non-form elements if contentEditable = true;\n       \tel.readOnly = false; // iOS will not select in a read only form element\n        var range = document.createRange();\n        range.selectNodeContents(el);\n        var sel = window.getSelection();\n        sel.removeAllRanges();\n        sel.addRange(range); // Does not work for Firefox if a textarea or input\n        \n        if (el.nodeName == \"TEXTAREA\" || el.nodeName == \"INPUT\") {\n            el.select(); // Firefox will only select a form element with select()\n        }\n    \t\n        if (el.setSelectionRange && navigator.userAgent.match(/ipad|ipod|iphone/i)) {\n            el.setSelectionRange(0, 999999); // iOS only selects \"form\" elements with SelectionRange\n        }\n    \t\n        el.contentEditable = editable; // Restore previous contentEditable status\n        el.readOnly = readOnly; // Restore previous readOnly status \n        \n        document.execCommand('copy');\n    }\n}"
273              },
274              "String size" : "sm",
275              "Boolean preventDefault" : true,
276              "xtype" : "Button",
277              "$ xns" : "Roo.bootstrap",
278              "String html" : "Copy Key",
279              "String style" : "margin-bottom: 15px;"
280             }
281            ]
282           }
283          ]
284         },
285         {
286          "xtype" : "Row",
287          "$ xns" : "Roo.bootstrap",
288          "items" : [
289           {
290            "xtype" : "Column",
291            "Number xs" : 12,
292            "$ xns" : "Roo.bootstrap",
293            "items" : [
294             {
295              "xtype" : "Container",
296              "$ xns" : "Roo.bootstrap",
297              "String well" : "sm",
298              "String html" : "5. After adding this to Authenticator app, type in the generated number below to confirm."
299             }
300            ]
301           }
302          ]
303         }
304        ]
305       }
306      ]
307     },
308     {
309      "xtype" : "Row",
310      "$ xns" : "Roo.bootstrap",
311      "items" : [
312       {
313        "xtype" : "Column",
314        "Number xs" : 12,
315        "$ xns" : "Roo.bootstrap",
316        "items" : [
317         {
318          "listeners" : {
319           "actionfailed" : "function (_self, action)\n{\n    if(action.type == 'submit') {\n        \n        switch(action.result.errorMsg) {\n            case '_invalid_auth_code':\n                Roo.bootstrap.MessageBox.alert(\n                    'Invalid authentication code',\n                    'Please re-enter the latest authentication code.'\n                );\n                break;\n            default:\n                Roo.log('invalid usage');\n                break;\n        }\n    }\n}",
320           "actioncomplete" : "function (_self, action)\n{\n    if(action.type == 'setdata') {\n        \n        this.clearInvalid();\n    }\n    \n    if(action.type == 'submit') {\n        \n        switch(action.result.data) {\n            \n            case 'DONE':\n                var cb = function() {\n                    _this.dialog.hide();\n                };\n                \n                Roo.bootstrap.MessageBox.alert('Success', 'Two Factor authentication has been enabled', cb);\n                return;\n                \n            default:\n                Roo.log('invalid usage');\n                break;\n        }\n    }\n}",
321           "render" : "function (_self)\n{\n    _this.form = this;\n}"
322          },
323          "xtype" : "Form",
324          "$ xns" : "Roo.bootstrap",
325          "String method" : "GET",
326          "$ String url" : "baseURL + '/Roo/Core_person.php'",
327          "items" : [
328           {
329            "Boolean allowBlank" : false,
330            "Number maxLength" : 6,
331            "Boolean allowZero" : false,
332            "String name" : "two_factor_auth_code",
333            "Boolean allowDecimals" : false,
334            "xtype" : "NumberField",
335            "string fieldLabel" : "Enter Two factor Authentication code",
336            "String labelAlign" : "top",
337            "Number xs" : 12,
338            "Number decimalPrecision" : 0,
339            "$ xns" : "Roo.bootstrap",
340            "Boolean allowNegative" : false,
341            "String indicatorpos" : "right"
342           },
343           {
344            "String name" : "id",
345            "xtype" : "Input",
346            "String inputType" : "hidden",
347            "$ xns" : "Roo.bootstrap"
348           }
349          ]
350         }
351        ]
352       }
353      ]
354     }
355    ]
356   }
357  ]
358 }