12 $self =
"$menu_link?ft=$ft";
13 $main_url = $menu_link;
15 $creditUnionKey = GetCreditUnionKey();
16 $creditUnionCookie = GetCreditUnionCookie();
18 $string = array(
"filter" => FILTER_SANITIZE_STRING);
19 $array = array(
"filter" => FILTER_DEFAULT);
21 HCU_ImportVars($SYSENV,
"LOGIN", array(
"mode" => $string,
"cu" => $string,
"username" => $string,
"confidence" => $string,
"challengeQuests" => $array,
"chksecure" => $string,
22 "password" => $string,
"email" => $string,
"clearCuCookie" => $string));
23 extract($SYSENV[
"LOGIN"]);
24 $cu= isset($cu) ? strtoupper(trim($cu)) :
"";
25 $clearCuCookie = isset($clearCuCookie) ? trim($clearCuCookie) :
"";
27 $cuMode= $cu !=
"" ?
"inRequest" :
"doesntExist";
30 if ($clearCuCookie ==
"Y")
32 HCU_setcookie_env($SYSENV, $creditUnionCookie,
"", 1,
"/");
33 HCU_setcookie_env($SYSENV,
"${creditUnionCookie}Hash",
"", 1,
"/");
35 else if (HCU_array_key_exists($creditUnionCookie, $_COOKIE))
37 $creditUnion = $_COOKIE[$creditUnionCookie];
38 $creditUnionHash = $_COOKIE[
"${creditUnionCookie}Hash"];
41 $cu = hcuOpenSSLDecrypt($creditUnion, $creditUnionHash,
"NONE");
46 $SYSENV[
"logger"]->error(
"Credit Union cookie failed: " . $e->getMessage());
50 $logger = $SYSENV[
"logger"];
52 $mode = isset($mode) ? trim($mode) :
"";
55 $searchList = array(
"'",
'"',
"+",
";" );
56 $username = (isset($username) ? str_replace( $searchList,
"", $username ) :
"");
57 $username = strtolower($username);
59 if (empty($_COOKIE[
'Tx_aURI']))
63 # NOTE: if username is NOT set we must be showing the login screen for the first time. If the Tx_aURI cookie is blank, set it to the main url. 64 HCU_setcookie_env($SYSENV,
"Tx_aURI", $main_url, 0,
"/");
65 $return_address = $main_url;
68 { ?> <html><head><title>Unable to Log In</title></head>
69 <body><h1>Unable to Log In</h1>
70 This site uses cookies
for its own security. Your browser must be capable of processing cookies <em>AND</em> cookies must be activated.
71 <br><br>Also,
if your system clock on your computer is
set incorrectly, you may have trouble connecting to
this site.
72 <br><br>Please
set your browser to accept cookies and check your clock, then press the <strong>reload</strong> button.
79 $return_address = urldecode($_COOKIE[
'Tx_aURI']);
81 $ip_address = $_SERVER[
'REMOTE_ADDR'];
90 checkChallenge($SYSENV, $dbh, $username, $cu, $challengeQuests);
91 showPasswordEntry($self, $username, $cu, $confidence,
true, $chksecure, $cuMode);
94 $passResult = checkPass($SYSENV, $dbh, $username, $password, $cu, $chksecure, $creditUnionCookie, $creditUnionKey);
95 if (!$passResult[
"expired"])
97 Set_aTicket($SYSENV, $passResult[
"cookie"],
"");
98 header(
"Location: $return_address");
102 header(
"Location: $main_url?ft=31");
108 $emailResult = checkEmail($dbh, $username, $email, $cu);
109 $challengeResult = getAdmChallengeQuestions($dbh, $cu, $username,
"login display");
110 $reqChal = $challengeResult[
"requireChallengeQuestions"];
111 $noRecords = $challengeResult[
"noRecord"];
112 $reqPassword = $challengeResult[
"forcePassword"];
114 $noRecords ? showChallengeQuestionEntry($self, $username, $cu, $email, $challengeResult[
"data"], $confidence, $cuMode)
115 : ($reqChal || $reqPassword ? showAccessEntry($self, $username, $cu, $email, $confidence, $cuMode)
116 : showChallengeQuestionEntry($self, $username, $cu, $email, $challengeResult[
"data"], $confidence, $cuMode));
119 $accessResult = checkPass($SYSENV, $dbh, $username, $password, $cu,
"N", $creditUnionCookie, $creditUnionKey,
true, $email);
120 $loc= $accessResult[
"forcePassword"] ? ($accessResult[
"forceSecurity"] ?
"ft=35" :
"ft=31")
121 : ($accessResult[
"forceSecurity"] ?
"ft=35" :
"");
122 header(
"Location: $main_url?$loc");
127 $memberResult = checkMember($dbh, $username, $cu);
128 $memberResult[
"getUsername"] ? showUsernameEntry($self, $cu, $memberResult[
"confidence"],
"", $cuMode) :
129 ($memberResult[
"additionalAuthentication"] ? showEmailEntry($self, $username, $cu, $memberResult[
"confidence"], $cuMode) :
130 showPasswordEntry($self, $username, $cu, $memberResult[
"confidence"], false,
"Y", $cuMode));
134 $pName = checkOrgName($cu);
135 showProductName($pName);
139 showUsernameEntry($self, $cu,
"", $e->getCode() >= 300 ? $e->getMessage() :
"Login failed", $cuMode);
154 function checkChallenge($SYSENV, $dbh, $username, $cu, $challengeQuests)
158 $challengeQuests = trim($challengeQuests);
159 if ($challengeQuests ==
"")
160 $challengeQuests = array(
"challenge" => 0,
"answers" => array());
163 $challengeQuests = HCU_JsonDecode($challengeQuests);
164 if (!is_array($challengeQuests))
166 $challengeQuests = array(
"challenge" => 0,
"answers" => array());
167 throw new Exception(
"Challenge Questions are not encoded correctly.", 1);
171 $challengeResult = getAdmChallengeQuestions($dbh, $cu, $username,
"login verify");
173 if (!$challengeResult[
"noRecord"])
175 foreach($challengeResult[
"data"] as $record)
177 $thisValue = HCU_array_key_value($record[
"quest_id"], $challengeQuests);
178 $thatValue = $record[
"answer"];
179 if ($thisValue !==
false && $thisValue != $thatValue)
180 throw new Exception(
"Challenge Answers are not valid.", 2);
186 if ($e->getCode() != 1)
188 $sth = db_query(
"select admfailmfa(cu, user_name,16, mfaquest) from cuadminusers where cu= '$cu' and user_name= '$username'", $dbh);
190 throw new exception (
"Fail query failed!", 2);
192 throw new exception(
"Invalid User Name or Challenge Response", 1);
205 function checkMember($dbh, $username, $cu)
210 $additionalAuthentication =
true;
211 $getUsername =
false;
213 $username = trim($username);
217 $forceResetConstant = GetAdminUserFlagsValue(
"ADM_FORCE_RESET");
219 extract(array(
"savepass" =>
"",
"savemail" =>
"",
"saveword" =>
"",
"freset" =>
"",
"failedremain" =>
"",
"fchange" =>
"",
"fremain" =>
"",
"mfaquest" =>
""));
222 $sql =
"select trim(au.passwd), trim(au.email), au.confidence, coalesce(au.userflags,0) & $forceResetConstant, au.failedremain, au.forcechange, au.forceremain, au.mfaquest 223 from cuadminusers au inner join cuadmin a on au.cu = a.cu where lower(au.user_name)='" . prep_save($username) .
"' and au.cu='" . prep_save($cu) .
"'";
225 $sth = db_query($sql,$dbh);
227 throw new Exception(
"Username query failed!", 2);
229 list($savepass, $savemail, $saveword, $freset, $failedremain, $fchange, $fremain, $mfaquest) = db_fetch_array($sth,0);
231 $numRows = db_num_rows($sth);
233 if (db_num_rows($sth) > 0)
235 if ($numRows >= 1 && ($failedremain <= 0 || (($fchange ==
'Y' || $freset != 0) && $fremain <=0)))
236 throw new Exception(
"Account is Locked.", 333);
238 $addToCookie = array();
239 $challengeArray = HCU_JsonDecode($mfaquest);
241 $challengeArray = HCU_array_key_value(
"answers", $challengeArray);
243 if (is_array($challengeArray))
245 ksort($challengeArray, SORT_NUMERIC);
246 $find= array(
"\n",
"\\",
"=",
"|");
247 $replace= array(
"",
"\\\\",
"\\=",
"\\|");
248 foreach($challengeArray as $questId => $questValue)
250 $questId = intval($questId);
251 $questValue = trim(str_replace($find, $replace, $questValue));
252 $addToCookie[] =
"$questId=$questValue";
255 $addToCookie = implode(
"|", $addToCookie);
257 $cookiename = sha1(
"HCUAdminTu0geethSaith7ch" . trim($username));
258 $cookiecontent = sha1(trim($savepass) . trim($savemail) . trim($saveword) . $addToCookie);
260 $additionalAuthentication = !isset($_COOKIE[$cookiename]) || $cookiecontent != $_COOKIE[$cookiename] || $freset != 0;
265 $returnArray= array(
"code" =>
"$code",
"error" =>
"$error",
"additionalAuthentication" => $additionalAuthentication,
"getUsername" => $getUsername,
"confidence" => $saveword);
279 function checkEmail($dbh, $username, $email, $cu)
286 $forceResetConstant = GetAdminUserFlagsValue(
"ADM_FORCE_RESET");
288 $email = trim($email);
289 $username = trim($username);
290 $sql =
"select au.userflags & $forceResetConstant::int, trim(au.email), au.mfaquest from cuadminusers au inner join cuadmin a on au.cu = a.cu 291 where lower(au.user_name) = '" . prep_save($username) .
"' and au.cu='" . prep_save($cu) .
"'";
292 $sth = db_query($sql,$dbh);
295 throw new Exception(
"Email query failed!", 1);
296 list($freset, $savemail, $challengeArray) = db_fetch_array($sth,0);
297 $savemail = trim($savemail);
299 if (trim($challengeArray) !=
"")
301 $challengeArray = HCU_JsonDecode($challengeArray);
302 if (!is_array($challengeArray))
303 throw new exception(
"Challenge Array not encoded correctly!", 3);
307 if (db_num_rows($sth) > 0 && $savemail !=
"" && strtolower($savemail) != strtolower($email))
309 $challengeArray[
"challenge"] = 0;
310 $sql =
"select admfailmfa('$cu', '$username',8, '" . prep_save(PrepareMfaQuestString($challengeArray)) .
"')";
312 $sth = db_query($sql, $dbh);
313 throw new Exception(
"Invalid User Name or Email", 2);
316 $returnArray= array(
"code" =>
"$code",
"error" =>
"$error");
336 .k-notification-wrap {
337 white-space: normal !important;
341 background-color: #eee !important;
362 function showBtnClicks($isChallenge, $self)
364 printCaptureEnter(); ?>
366 $(
"#submitBtn").click(
function() {
367 if ($.homecuValidator.validate())
369 var form = $(
this).closest(
"form");
370 <?php
if ($isChallenge) { ?>
371 var challengeQuests= {};
372 $(
".challengeRow").each(
function() {
373 challengeQuests[$(
this).data(
"questid")] = $(
this).find(
".questionInput").val().trim();
375 $(form).append(
"<input type='hidden' name='challengeQuests' value='" + kendo.stringify(challengeQuests) +
"'>");
383 $(
"#clearBtn").click(
function() {
384 window.location.href =
"<?php echo $self; ?>";
398 function showUsernameEntry($self, $cu, $confidence, $errorMessage, $cuMode)
402 if ($cuMode ==
"doesntExist")
405 $userAutofocus =
false;
409 $cuAutofocus =
false;
410 $userAutofocus =
true;
412 $errorMessage = is_null($errorMessage) ? array() : (is_array($errorMessage) ? $errorMessage : (trim($errorMessage) ==
"" ? array() : array(trim($errorMessage))));
414 <script type=
'text/javascript'>
417 $.homecuValidator.setup({formValidate:
'login-entry', formStatusField:
'formStatus'});
418 <?php
if ($errorMessage !=
"") { ?>
419 $.homecuValidator.displayMessage(<?php echo HCU_JsonEncode($errorMessage) ?>, $.homecuValidator.settings.statusError);
421 showBtnClicks(
false, $cuMode ==
"inRequest" ?
"$self&cu=$cu" : $self); ?>
424 $(document).ready(
function() {
429 <div
class=
"container-fluid"><div
class=
"row-fluid">
430 <form
id=
"login-entry" method=
"post" action=
"<?php echo $self; ?>" role=
"form" data-role=
"validator" novalidate=
"novalidate">
431 <input type=
"hidden" name=
'chksecure' value=
'Y'>
432 <input type=
"hidden" name=
'mode' value=
'ChkMember'>
433 <input type=
"hidden" name=
'confidence' value=
'<?php echo $confidence; ?>'>
434 <div
id=
"formStatus" class=
"k-block k-error-colored formStatus" style=
"display:none;"></div>
435 <div
class=
"well well-sm">
436 <div
class=
"form-horizontal form-widgets">
437 <?php printHeader(
"Enter User Credentials");
438 if ($cuMode ==
"inTicket")
439 loginPrintLabelBlock(array(
"HomeCU Code (<a href=\"$self&clearCuCookie=Y\" class=\"cuClearBtn\">Not $cu?</a>)" => $cu));
441 loginPrintInputLine(
"HomeCU Code", $cu,
"cu", 10, $cuAutofocus,
true,
"text",
"CU is required");
443 loginPrintInputLine(
"Username",
"",
"username", 50, $userAutofocus,
true,
"text",
"Username is required"); ?>
446 <div
class=
"form-horizontal form-widgets">
447 <?php loginPrintButtons(
false,
false); ?>
465 function showPasswordEntry($self, $username, $cu, $confidence, $isAfterConfidence, $chksecure, $cuMode)
469 <script type=
'text/javascript'>
472 $.homecuValidator.setup({formValidate:
'login-entry', formStatusField:
'formStatus'});
473 <?php showBtnClicks(
false, $cuMode ==
"inRequest" ?
"$self&cu=$cu" : $self); ?>
476 $(document).ready(
function() {
481 <div
class=
"container-fluid"><div
class=
"row-fluid">
482 <form
id=
"login-entry" method=
"post" action=
"<?php echo $self; ?>" role=
"form" data-role=
"validator" novalidate=
"novalidate">
483 <input type=
"hidden" name=
'cu' value=
'<?php echo $cu ?>'>
484 <input type=
"hidden" name=
'chksecure' value=
'<?php echo $chksecure; ?>'>
485 <input type=
"hidden" name=
'mode' value=
'ChkPass'>
486 <input type=
"hidden" name=
'username' value=
'<?php echo $username; ?>'>
487 <div
class=
"well well-sm">
488 <div
class=
"form-horizontal form-widgets">
490 printHeader(
"Enter User Credentials");
491 loginPrintLabelBlock(array(
"Username" => $username,
"Your Confidence Word is" => $confidence));
492 loginPrintInputLine(
"Password",
"",
"password", 225,
true,
true,
"password",
"password is required"); ?>
495 <div
class=
"form-horizontal form-widgets">
496 <?php loginPrintButtons(
true); ?>
513 function showEmailEntry($self, $username, $cu, $confidence, $cuMode)
517 <script type=
'text/javascript'>
520 $.homecuValidator.setup({formValidate:
'login-entry', formStatusField:
'formStatus'});
521 <?php showBtnClicks(
false, $cuMode ==
"inRequest" ?
"$self&cu=$cu" : $self); ?>
524 $(document).ready(
function() {
529 <div
class=
"container-fluid"><div
class=
"row-fluid">
530 <form
id=
"login-entry" method=
"post" action=
"<?php echo $self; ?>" role=
"form" data-role=
"validator" novalidate=
"novalidate">
531 <input type=
"hidden" name=
'cu' value=
'<?php echo $cu ?>'>
532 <input type=
"hidden" name=
'chksecure' value=
'Y'>
533 <input type=
"hidden" name=
'mode' value=
'ChkEmail'>
534 <input type=
"hidden" name=
'username' value=
'<?php echo $username; ?>'>
535 <input type=
"hidden" name=
'confidence' value=
'<?php echo $confidence; ?>'>
536 <div
id=
"formStatus" class=
"homecu-formStatus k-block k-error-colored formStatus" style=
"display:none;"></div>
537 <div
class=
"well well-sm">
538 <div
class=
"form-horizontal form-widgets">
540 printHeader(
"Enter User Credentials");
541 loginPrintLabelBlock(array(
"Username" => $username));
542 loginPrintInputLine(
"Confirm Email Address",
"",
"email", 50,
"autofocus data-email-msg='Email is not valid'",
true,
"email",
"Email is required"); ?>
545 <div
class=
"form-horizontal form-widgets">
546 <?php loginPrintButtons(); ?>
565 function showChallengeQuestionEntry($self, $username, $cu, $email, $challengeQuestions, $confidence, $cuMode)
569 <script type=
'text/javascript'>
572 $.homecuValidator.setup({formValidate:
'login-entry', formStatusField:
'formStatus'});
573 <?php showBtnClicks(
true, $cuMode ==
"inRequest" ?
"$self&cu=$cu" : $self); ?>
575 $(
"#publicNote").click(
function(e) {
576 var position = $(
this).offset();
577 var notification = $(
"<div></div>").appendTo(
"body").kendoNotification({
584 }).data(
"kendoNotification");
586 notification.info(
'Public computers are found at libraries, schools, Internet cafes, airports, and many other places. <br>You have no control over who uses public computers. \ 587 <br>Public computers may be running malicious software like keystroke loggers or be on networks that allow others to get your personal information. \ 588 <br><br>We strongly suggest you do <i>NOT</i> use a public computer for digital banking. <br>If you decide to use one anyway, you should check the box so we do not save a security \ 589 token to this public computer.');
593 $(
"[name='question0']").focus();
596 $(document).ready(
function() {
601 <div
class=
"container-fluid"><div
class=
"row-fluid">
602 <form
id=
"login-entry" method=
"post" action=
"<?php echo $self; ?>" role=
"form" data-role=
"validator" novalidate=
"novalidate">
603 <input type=
"hidden" name=
'cu' value=
'<?php echo $cu; ?>'>
604 <input type=
"hidden" name=
'mode' value=
'ChkChallenge'>
605 <input type=
"hidden" name=
'email' value=
'<?php echo $email; ?>'>
606 <input type=
"hidden" name=
'username' value=
'<?php echo $username; ?>'>
607 <input type=
"hidden" name=
'confidence' value=
'<?php echo $confidence; ?>'>
608 <div
id=
"formStatus" class=
"homecu-formStatus k-block k-error-colored formStatus" style=
"display:none;"></div>
609 <div
class=
"well well-sm ">
610 <div
class=
"form-horizontal form-widgets">
612 printHeader(
"Enter User Credentials");
613 loginPrintLabelBlock(array(
"Username" => $username));
614 if (count($challengeQuestions) > 1) {
615 printHeader(
"Please Answer the Following Challenge Question(s)");
617 printHeader(
"Please Answer the Following Challenge Question");
619 for($i=0, $length= count($challengeQuestions); $i != $length; $i++) {
620 extract($challengeQuestions[$i]);
622 <div
class=
"form-group challengeRow <?php $i == 0 ? 'hcuSpacer' : ''; ?>">
623 <label
class=
"col-xs-12 col-md-8 challengeQuestion"><?php echo $quest_text; ?></label>
624 <div
class=
"col-xs-12 col-md-8 ">
625 <input name=
"question<?php echo $i; ?>" class=
"questionInput hcu-all-100 k-input k-textbox" 626 required data-required-msg=
"The response for question <?php echo $i+1; ?> was left blank" maxlength=
"50" <?php echo $i == 0 ?
"autofocus" :
"" ?>>
628 <div
class=
"col-xs-1 col-sm-1">
629 <span data-
for=
'question<?php echo $i; ?>' class=
'k-invalid-msg'></span>
634 <div
class=
"form-horizontal form-widgets">
635 <?php loginPrintButtons(
false,
true); ?>
637 <?php loginPrintSaveToken(); ?>
651 function showAccessEntry($self, $username, $cu, $email, $cuMode)
655 <script type=
'text/javascript'>
658 $.homecuValidator.setup({formValidate:
'login-entry', formStatusField:
'formStatus'});
659 <?php showBtnClicks(
false, $cuMode ==
"inRequest" ?
"$self&cu=$cu" : $self); ?>
662 $(document).ready(
function() {
667 <div
class=
"container-fluid"><div
class=
"row-fluid">
668 <form
id=
"login-entry" method=
"post" action=
"<?php echo $self; ?>" role=
"form" data-role=
"validator" novalidate=
"novalidate">
669 <input type=
"hidden" name=
'cu' value=
'<?php echo $cu; ?>'>
670 <input type=
"hidden" name=
'mode' value=
'ChkAccess'>
671 <input type=
"hidden" name=
'email' value=
'<?php echo $email; ?>'>
672 <input type=
"hidden" name=
'username' value=
'<?php echo $username; ?>'>
673 <div
id=
"formStatus" class=
"homecu-formStatus k-block k-error-colored formStatus" style=
"display:none;"></div>
674 <div
class=
"well well-sm ">
675 <div
class=
"form-horizontal form-widgets">
677 printHeader(
"Enter User Credentials");
678 loginPrintLabelBlock(array(
"Username" => $username));
679 loginPrintInputLine(
"Please enter your password",
"",
"password", 225,
true,
true,
"password",
"password is required"); ?>
682 <div
class=
"form-horizontal form-widgets">
683 <?php loginPrintButtons(); ?>