Odyssey
Login.i
1 <?php
2  /**
3  * File: Login.i
4  *
5  * Purpose: New Feature Gated Login process of authentication
6  * No longer contains additional steps of email authentication
7  * or confidecne word. Simplified process with separate Login.data
8  * file for most php code, called with AJAX.
9  *
10  * Created: 10/2019
11  */
12 
13  $payload = '';
14  // checking for posted values to encode
15  if (isset($HB_ENV['HCUPOST']['username']) && isset($HB_ENV['HCUPOST']['password']) && isset($HB_ENV['HCUPOST']['cu'])){
16 
17  $payload = json_encode(array('username' => $HB_ENV['HCUPOST']['username'],'password' => $HB_ENV['HCUPOST']['password'], 'cu' => $HB_ENV['HCUPOST']['cu']));
18 
19  $payload = HCU_PayloadEncode($HB_ENV['HCUPOST']['cu'], $payload, true);
20 
21  }
22 
23  ?>
24  <html>
25  <head>
26  <title><?php echo hcu_displayHtml($HB_ENV['orgname']); ?></title>
27  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
28  <meta name="robots" content="noindex,nofollow,noarchive,nocache" />
29  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
30  <meta name="referrer" content="always">
31  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
32 
33  <!--Bootsrap 4 CDN-->
34  <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
35 
36  <!--Fontawesome CDN-->
37  <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.3.1/css/all.css" integrity="sha384-mzrmE5qonljUremFsqc01SB46JvROS7bZs3IO2EmfFsd15uHvIt+Y8vEf7N7fWAU" crossorigin="anonymous">
38 
39  <?php
40  print setIncludeFiles(true, true, HCU_array_key_value("contentTheme", $cuSettings), true, $HB_ENV, $MC);
41 
42  ?>
43 
44  <!-- New Login CSS -->
45  <link rel='stylesheet' media='all' type='text/css' href='/banking/static/css/login.css' >
46 
47  <script>
48  // Using Ajax calls to Login.data where login logic lives
49  $(document).ready(function() {
50 
51  // cookie notification
52  <?php if ($HB_ENV["platform"] !== "ADA" && $HB_ENV["platform"] !== "APP") { ?>
53  if (document.cookie.search('cookieAccepted=true') < 0) {
54  var toast = new CinnaToast({'position': 'bottom-middle', 'showFor': 0});
55  toast.show("<?php echo $MC->msg('Using cookies'); ?>", [{'text':"<?php echo $MC->msg('Using cookies button'); ?>", 'action':
56  function(){
57  var date = new Date('2038-01-19 04:14:07');
58  document.cookie = "cookieAccepted=true; expires=" + date.toUTCString()+ "; path=/";
59  toast.hide();
60  }
61  }]);
62  toast.focus();
63  }
64  <?php } ?>
65 
66  $.homecuValidator.setup({formErrorTitle: "<?php echo $MC->msg("Error Occurred", HCU_DISPLAY_AS_JS) ?>"});
67 
68  $("stepone").hide();
69  $("#login-promo").hide();
70  $("#login-footer").hide();
71  $("#steptwo").hide();
72  $("#setup").hide();
73 
74  //static variables
75  var loginStep = '';
76  var cu = "<?php echo $HB_ENV['Cu'] ?>";
77  var homebankingpath = "<?php echo $HB_ENV['homebankingpath'] ?>";
78  var logoSrc = "<?php echo $cuSettings['imageLocations']['desktopCULogoLocation']; ?>";
79  var payload = "<?php echo $payload ?>";
80  var platform = "<?php echo $HB_ENV["platform"] ?>";
81 
82  // setting enroll link
83  var activatePath = "<?php echo $HB_ENV['loginpath'] . "/hcuActivate.prg?" . $HB_ENV['cuquery'] ?>"
84  $("#enroll").attr("href", activatePath);
85 
86  // setting forgot link
87  var forgotPath = "<?php echo $HB_ENV['loginpath'] . "/hcuResetPwd.prg?" . $HB_ENV['cuquery'] ?>"
88  $("#forgot").attr("href", forgotPath);
89 
90  // setting accounts link
91  var accountPath = "<?php echo $HB_ENV['loginpath'] . "/hcuAccounts.prg?" . $HB_ENV['cuquery'] ?>"
92 
93  $('#logoImg').attr("src",logoSrc);
94 
95  // if payload values exist, try to validate
96  if (payload) {
97  // Validate User
98  $.ajax({
99  url: "Login.data",
100  async: false,
101  type: "POST",
102  dataType: 'json',
103  data: {action: 'ValidateUser', cu: cu, homebankingpath: homebankingpath, payload: payload, platform: platform},
104  success: function (response) {
105  try {
106  if (response){
107  if (response.errors) {
108  //show errors
109  $.homecuValidator.settings.formErrorTitle = '<?php echo $MC->msg('Error Occurred', HCU_DISPLAY_AS_JS); ?>';
110  $.homecuValidator.settings.formStatusField = "loginFormStatus";
111  $.homecuValidator.displayMessage(response.errors, $.homecuValidator.settings.statusError);
112  } else {
113  // success, go to next step
114  loginStep = response.data.Step;
115  }
116  }
117  } catch (err) {
118  // do nothing
119  }
120  },
121  error: function (response) {
122  // do nothing
123  }
124  });
125  }
126 
127  // Pull in Login Notices
128  $.ajax({
129  url: "Login.data",
130  type: "POST",
131  dataType: 'json',
132  data: {action: 'LoginNotices', cu: cu, homebankingpath: homebankingpath, platform: platform},
133  success: function (response) {
134  var returnData = Array();
135  try {
136  if (response.data.status.code === '000'){
137  // success
138  if ((response.data.notice).length > 0) {
139  notice = JSON.parse(JSON.stringify(response.data.notice[0].notice_text));
140  $("#login-footer").append(notice);
141  $("#login-footer").show();
142  } else {
143  $("#login-footer").hide();
144  }
145  } else {
146  // problem
147  $("#login-footer").hide();
148  }
149  } catch (err) {
150  // do nothing
151  }
152  },
153  error: function (response) {
154  // do nothing
155  }
156  });
157 
158  // Pull in Login Promos
159  $.ajax({
160  url: "Login.data",
161  type: "POST",
162  dataType: 'json',
163  data: {action: 'LoginPromos', cu: cu, homebankingpath: homebankingpath, platform: platform},
164  success: function (response) {
165  var returnData = Array();
166  try {
167  if (response.data.status.code === '000'){
168  // success
169  if ((response.data.notice).length > 0) {
170  notice = JSON.parse(JSON.stringify(response.data.notice[0].notice_text));
171  $("#login-promo").append(notice);
172  $("#login-promo").show();
173  } else {
174  $("#login-promo").hide();
175  }
176  } else {
177  // problem
178  $("#login-promo").hide();
179  }
180  } catch (err) {
181  // do nothing
182  }
183 
184  },
185  error: function (response) {
186  // do nothing
187  }
188  });
189 
190  if (loginStep === '') {
191  $("#stepone").show();
192  } else if (loginStep === 'MFA' || loginStep === 'Challenge') {
193  $("#stepone").hide();
194  $("#steptwo").show();
195  $("#setup").hide();
196  } else if (loginStep === 'Setup') {
197  $("#stepone").hide();
198  $("#steptwo").hide();
199  $("#setup").show();
200  } else if (loginStep === 'None') {
201  // user had valid cookie - continue to accounts
202  window.location.href = accountPath;
203  }
204 
205  $('#btnLogin').on('click', function () {
206 
207  var loginid = $("#username").val();
208  var password = $("#password").val();
209 
210  if (loginid === '' || password === '') {
211  $.homecuValidator.settings.formErrorTitle = '<?php echo $MC->msg('Error Occurred', HCU_DISPLAY_AS_JS); ?>';
212  $.homecuValidator.settings.formStatusField = "loginFormStatus";
213 
214  $.homecuValidator.displayMessage("Login ID and Password are required", $.homecuValidator.settings.statusError);
215  }
216 
217  // if ($.homecuValidator.homecuValidate) {
218  // // ShowWaitWindow();
219  // }
220  });
221 
222  // If Step 2 then Pull Challenge Question or SAC
223  // $.ajax({
224  // url: "Login.data",
225  // type: "POST",
226  // dataType: 'json',
227  // data: {action: 'ChallengeQuestion', cu: cu, homebankingpath: homebankingpath, username: username},
228  // success: function (response) {
229  // var returnData = Array();
230  // try {
231  // if (response.status.code === '000'){
232  // // success
233  // if (response) {
234  // alert(JSON.stringify(response));
235  // }
236  // } else {
237  // // problem
238  // }
239  // } catch (err) {
240  // // do nothing
241  // }
242  // },
243  // error: function (response) {
244  // // do nothing
245  // }
246  // });
247 
248  // If Step 2 and SAC, pull emails and phone numbers
249 
250  // $.homecuValidator.setup({formValidate: 'loginFrm', formStatusField: 'formStatus', validateOnClick: 'loginBtn'});
251 
252  $(".hcu-lang-toggle").on("click", function(){
253  var lang = this.name;
254  ChangeLanguage(lang);
255  });
256 
257  function ChangeLanguage(langCode) {
258  if (langCode !== '' && langCode !== '<?php echo $HB_ENV['Flang']; ?>') {
259  postData = "homecuLang=" + langCode;
260  $.post('<?php echo $HB_ENV['loginpath'] . "/hcuSetLang.prg?" . $HB_ENV['currentQuery']; ?>', postData, function(data) {}, 'json')
261  .done(function(data) {
262  try {
263  if (data.homecuInfo == 'OK') {
264  // ** After setting the language, reload the current page
265  document.location = '<?php echo $HB_ENV['loginpath'] . "/" . $HB_ENV['currentscript'] . "?" . $HB_ENV['currentQuery']; ?>';
266  }
267  } catch (err) {
268  // * There seems to be a syntax error of sorts. -- do nothing at moment
269  }
270  });
271  }
272  return false;
273  }
274 
275  $('#btnStartOver').click(function () {
276  window.location = '<?php echo $HB_ENV['loginpath'] . "/" . $HB_ENV['currentscript'] . "?" . $HB_ENV['cuquery']; ?>';
277  });
278 
279  });
280  </script>
281 </head>
282  <body>
283  <div id="loginContent">
284  <!-- Logo -->
285  <div class="logoDiv">
286  <div class="d-flex justify-content-center">
287  <div class="logo-card" id="header">
288  <div class="d-flex justify-content-center">
289  <img id="logoImg" alt="Digital Banking Logo" class="logo" src=""/>
290  </div>
291  <!-- Pulling language options - copied from hcuPreContent.i -->
292  <?php if (count($cuSettings['language']) > 1): ?>
293  <div class="d-flex desk-lang-select" role="menu">
294  <?php
295  foreach ($cuSettings['language'] as $langKey => $langValue) {
296  if ($langKey != $HB_ENV['Flang']) {
297  ?>
298  <a href="#" class="hcu-lang-toggle" name="<?php echo $langKey; ?>" title="Select <?php echo $langValue; ?>"><div class="flag_icons flag_icons_<?php echo $langKey; ?>"></div></a>
299  <?php
300  }
301  }
302  ?>
303  </div>
304  <?php endif; ?>
305  </div>
306  </div>
307  </div>
308  <div id="loginFormStatus" class="homecu-formStatus k-block k-error-colored" style="display:none; margin-bottom:10px;max-width:800px;"></div>
309  <!-- Step 1 Username and Password -->
310  <div class="container" id="stepone">
311  <div class="d-flex justify-content-center">
312  <div class="card">
313  <div class="card-header">
314  <h3><?php echo $MC->msg('Login Title', HCU_DISPLAY_AS_HTML)?></h3>
315  <div class="d-flex justify-content-end social_icon">
316  </div>
317  </div>
318  <div class="card-body">
319  <form id='loginFrm' role="form" method="post">
320  <input type='hidden' name="step" value="Member" />
321  <div class="input-group form-group">
322  <div class="input-group-prepend">
323  <span class="input-group-text"><i class="fas fa-user"></i></span>
324  </div>
325  <input type="text" class="form-control" placeholder="<?php echo $MC->msg('Login ID', HCU_DISPLAY_AS_HTML)?>" required aria-label="<?php echo $MC->msg('Login ID', HCU_DISPLAY_AS_HTML)?>" id="username" name="username">
326  </div>
327  <div class="input-group form-group">
328  <div class="input-group-prepend">
329  <span class="input-group-text"><i class="fas fa-lock"></i></span>
330  </div>
331  <input type="password" class="form-control" placeholder="<?php echo $MC->msg('Password', HCU_DISPLAY_AS_HTML)?>" required aria-label="<?php echo $MC->msg('Password', HCU_DISPLAY_AS_HTML)?>" id="password" name="password">
332  </div>
333  <div class="form-group">
334  <div class="d-flex justify-content-end">
335  <input id="btnLogin" name="btnLogin" type="submit" value="<?php echo $MC->msg('Log In', HCU_DISPLAY_AS_HTML)?>" class="k-button k-primary btn-primary btn login_btn">
336  </div>
337  </div>
338  <div class="form-group">
339  <div class="d-flex justify-content-start">
340  <?php if ($HB_ENV['flagset'] & $CU_MEMRESET) { ?>
341  <a href="#" id="forgot"><?php echo $MC->msg('Forgot your password', HCU_DISPLAY_AS_HTML); ?></a>
342  <?php } ?>
343  </div>
344  </div>
345  </form>
346  </div>
347  <div class="card-footer">
348  <?php if ($HB_ENV['flagset3'] & $CU3_SHOW_ENROLL): ?>
349  <div class="d-flex justify-content-center links">
350  <?php echo $MC->msg("New To Home Banking", HCU_DISPLAY_AS_HTML); ?><a href="#" id="enroll"><?php echo $MC->msg("Enroll Now", HCU_DISPLAY_AS_HTML); ?></a>
351  </div>
352  <?php endif; ?>
353  </div>
354  </div>
355  </div>
356  <!-- Start of Login Promo Info -->
357  <div class="d-flex justify-content-center">
358  <div class="login-promo" id='login-promo'>
359  </div>
360  </div>
361  <!-- Start of Footer Notice Info -->
362  <div class="d-flex justify-content-center">
363  <div class="login-footer" id='login-footer'>
364  </div>
365  </div>
366  </div>
367  <!-- Step 2 MFA -->
368  <div class="container" id="steptwo">
369  <div class="d-flex justify-content-center">
370  <div class="large-card">
371  <div class="card-header">
372  <h3>Additional Authentication</h3>
373  </div>
374  <div class="card-body">
375  <form id='authFrm' role="form">
376  <div class="input-group form-group">
377  <label><?php echo $MC->msg('Login ID', HCU_DISPLAY_AS_HTML); ?>:</label>
378  <div class="col-xs-12" >
379  <p class="text-muted">TESTUSER</p>
380  </div>
381  </div>
382  <div class="input-group form-group challenge">
383  <label for="qid">This is a sample challenge question?</label>
384  </div>
385  <div class="input-group form-group challenge">
386  <input id="qid" type="text" class="form-control" placeholder="Answer" required aria-label="Answer">
387  </div>
388  <div class="form-group">
389  <div class="d-flex custom-control custom-switch">
390  <input type="checkbox" class="custom-control-input" id="rememberSwitch">
391  <label class="custom-control-label" for="rememberSwitch">Remember This Device</label>
392  </div>
393  </div>
394  <!-- <div class="input-group form-group sac">
395  <label class="text-muted"><?php echo $MC->msg('Login Select SAC Destination', HCU_DISPLAY_AS_HTML); ?></label>
396  </div>
397  <div class="input-group form-group sac">
398  <label for="emails">Email to</label>
399  </div>
400  <div class="input-group form-group sac">
401  <label for="sac_deliver_email"><input type="radio" id="sac_deliver_email" value="e..n@homecu.com"> e..n@homecu.com</label>
402  </div>
403  <div class="input-group form-group sac">
404  <label for="phones">Text to</label>
405  </div>
406  <div class="input-group form-group sac">
407  <label for="sac_deliver_phone"><input type="radio" id="sac_deliver_phone" value="xxx-xxx-5555"> xxx-xxx-5555</label>
408  </div> -->
409  <div class="form-group">
410  <div class="d-flex flex-row-reverse flex-wrap">
411  <input id="authBtn" name="authBtn" type="submit" value="<?php print $MC->msg('Continue', HCU_DISPLAY_AS_HTML); ?>" class="k-button k-primary btn-primary btn auth_btn">
412  <a href="#" id="btnStartOver" name="btnStartOver" class="btnStartOver"><?php print $MC->msg('Start Over', HCU_DISPLAY_AS_HTML); ?></a>
413  </div>
414  </div>
415  </form>
416  </div>
417  </div>
418  </div>
419  </div>
420  <!-- Setup Challenge Questions -->
421  <div class="container" id="setup">
422  <div class="d-flex justify-content-center">
423  <div class="large-card">
424  <div class="card-header">
425  <h3>Setup Challenge Questions</h3>
426  </div>
427  <div class="card-body">
428  <form id='setupFrm' role="form">
429 
430  </form>
431  </div>
432  </div>
433  </div>
434  </div>
435 
436  <!-- Google Analytics -->
437  <?php
438  $platform = "desktop";
439  if ( $HB_ENV["platform"] == "ADA" ) {
440  $platform = "android";
441  } else if ( $HB_ENV["platform"] == "APP" ) {
442  $platform = "ios";
443  } else if ( $HB_ENV["platform"] == "MBL" ) {
444  $platform = "mobile";
445  }
446  ?>
447 
448  <script>
449  window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date;
450  ga('create', 'UA-122960060-1', 'auto');
451  ga('send', 'pageview', {
452  'dimension1': "<?php echo $HB_ENV['cuhost'] ?>" , // which server
453  'dimension2': "<?php echo $HB_ENV['cu'] ?>" , // cu identifier
454  'dimension4': "<?php echo $serviceViewFromCuAdmin ? "admin" : "user" ?>", // is this a login or a view from admin
455  'dimension5': "<?php echo $platform ?>", // desktop, mobile, ios, android
456  'dimension6': "" // version
457  });
458  </script>
459  <script async src='https://www.google-analytics.com/analytics.js'></script>
460  <!-- End Google Analytics -->
461  </div>
462  </body>
463 </html>