10 $serviceShowInfo =
true;
11 $serviceLoadMenu =
true;
12 $serviceShowMenu =
true;
15 require_once(dirname(__FILE__) .
'/../library/hcuService.i');
21 PermCheckFeatureScreen($dbh, $HB_ENV, $MC, FEATURE_BASIC);
24 $dms_ok = array(
"security_curpwd"=>
"string",
"security_token"=>
"string");
26 dms_import_v2($HB_ENV,
'HCUPOST', $dms_ok);
31 require_once(dirname(__FILE__) .
'/../includes/hcuPreContent.i');
36 $randomNbr = Return_Random4Challenge($HB_ENV);
39 $aryMbrChg = Get_MemberChallengeResponses($dbh, $HB_ENV, $HB_ENV[
'Cn']);
45 if ($HB_ENV[
'HCUPOST'][
'security_curpwd'] !=
'') {
48 $validPwd[
'settings_password'][
'current'] = $HB_ENV[
'HCUPOST'][
'security_curpwd'];
49 $aryUpdate = Validate_Settings($dbh, $HB_ENV, $validPwd, $MC);
51 if ($aryUpdate[
'status'][
'code'] ==
'000') {
54 $mbrPwd = GetUserInfo($dbh, $HB_ENV, $MC, Array(
"user_id" => $HB_ENV[
'Uid'],
"cu" => $HB_ENV[
'Cu']));
56 if ($mbrPwd[
'status'][
'code'] !=
'000') {
58 $errorList = array(
"id" =>
"",
"message" => $mbrPwd[
'status'][
'errors'] );
61 $mbrPwdHash = $mbrPwd[
'data'][
'cuusers_passwd'];
65 foreach ($aryMbrChg as $questId => $questResp) {
66 $choices[] = $questId;
69 $choiceString = implode( $choices );
73 $securityToken = sha1($mbrPwdHash . $randomNbr . $choiceString . $HB_ENV[
'secret']);
75 $retAry[
'data'][
'security_token'] = $securityToken;
80 $errorList = array(
"id" =>
"",
"message" => $MC->msg(
'Invalid Authentication', HCU_DISPLAY_AS_RAW) );
85 $errorList = array(
"id" =>
"",
"message" => $MC->msg(
'Invalid Authentication', HCU_DISPLAY_AS_RAW) );
95 if ( $act ==
"auth" ) {
100 $randomNbr = rand(1000, 9999);
101 $cookieName =
"PWDCHG";
102 $cookieExpires = time() + (60 * 15);
103 $p3 = MD5($HB_ENV[
'secret'] . MD5(join (
':', array($randomNbr, $cookieExpires))));
104 $cookieValue =
"p1={$randomNbr}&p2={$cookieExpires}&p3={$p3}";
107 HCU_setcookie_env($HB_ENV[
'SYSENV'], $cookieName, $cookieValue, 0);
108 }
else if ( $act ==
"settings" ) {
110 $mbrConfidence = $mbrPwd[
"data"][
"cuusers_confidence"];
113 $aryPhones = array();
116 FROM {$HB_ENV['Cu']}usercontact c 117 LEFT JOIN {$HB_ENV['Cu']}user u 118 ON u.contact = c.contact_id 119 WHERE u.user_name = '{$HB_ENV['Cn']}'";
120 $sqlRs = db_query($sql, $dbh);
122 $aryPhones = db_fetch_assoc($sqlRs, 0);
123 if ($aryPhones[
'phones'] ===
null) {
128 $aryPhones = HCU_JsonDecode($aryPhones[
'phones']);
133 $aryChallengeQuestions = GetChallengeQuestions(
"DISPLAY", $dbh, $HB_ENV, $MC);
134 $aryCurrentQuestions = GetChallengeQuestions(
"CURRENT", $dbh, $HB_ENV, $MC, $HB_ENV[
'Cn']);
142 foreach ($aryChallengeQuestions as $chgKey => $chgValue) {
143 $chgValue[
'display'] = html_entity_decode($chgValue[
'display'], ENT_QUOTES,
'UTF-8');
144 $aryChallengeQuestions[$chgKey] = $chgValue;
146 reset($aryChallengeQuestions);
147 if ( count( $aryMbrChg ) ) {
148 $formPopulate = array();
149 foreach ($aryMbrChg as $questId => $questResp) {
150 $formPopulate[] = array(
"security_qst" => $questId,
"security_rsp" => $questResp );
153 for ( $i = 0; $i < $HB_ENV[
'cu_chgqst_count']; $i++ )
154 $formPopulate[] = array(
"security_qst" => $aryChallengeQuestions[0][
"cqid"],
"security_rsp" =>
"" );
160 <script type=
"text/javascript">
162 $(document).ready(
function() {
164 $(
"#formSecurity").on(
"submit",
function(e) {
168 <?php
if ($act ===
"settings") { ?>
170 var hcuChallengeQuestions = <?php print HCU_JsonEncode($aryChallengeQuestions); ?>;
171 var hcuCurrentQuestions = <?php print HCU_JsonEncode($aryCurrentQuestions); ?>;
172 var hcuPhonesList = <?php print HCU_JsonEncode($aryPhones); ?>;
173 var hcuPhonesData = [];
175 if (hcuPhonesList.mobile) {
176 for (var i = 0; i < hcuPhonesList.mobile.length; i++) {
177 var phone = hcuPhonesList.mobile[i];
178 var phoneParts = hcuPhonesList.mobile[i].split(/[-\s]/);
181 if (phoneParts.length === 3) {
182 phone +=
"(" + phoneParts[0].replace(/\D/g,
'') +
") ";
183 phone += phoneParts[1] +
"-";
184 phone += phoneParts[2];
186 phone += phoneParts[0] +
"-";
187 phone += phoneParts[1];
198 if (hcuPhonesData.length < 5) {
208 function ShowStatus( statusMessage ) {
209 $.homecuValidator.settings.formStatusField =
"formStatus";
210 $.homecuValidator.settings.formInfoTitle =
"";
211 $.homecuValidator.displayMessage(statusMessage);
214 function ClearStatus( ) {
215 $.homecuValidator.settings.formStatusField =
"formStatus";
216 $.homecuValidator.settings.formInfoTitle =
"";
217 $.homecuValidator.displayMessage(
null);
220 function validateForm() {
222 var valid = $.homecuValidator.validate();
224 var grid = $(
"#phoneGrid").data(
"kendoGrid");
225 var data = grid.dataSource.data();
226 var regex =
new RegExp(/^[2-9]\d{2}-\d{3}-\d{4}$/);
228 for (var i = 0; i < data.length; i++) {
235 var phone = data[i].value;
236 phone = phone.replace(/[_\(\)]/g,
'');
237 phone = phone.replace(/\s/g,
'-');
238 var phoneValid = regex.test(phone);
241 if (phoneValid ===
false) {
243 var message =
"<?php echo $MC->msg("Phone Invalid
", HCU_DISPLAY_AS_JS); ?>";
244 var errors = $.homecuValidator.homecuKendoValidator.errors();
245 var show = errors.concat(message);
247 $.homecuValidator.displayMessage(show, $.homecuValidator.settings.statusError);
254 function phoneEdit(container, options) {
255 var maskedTextBox = $(
"<input name=\"" + options.field +
"\">")
257 .kendoMaskedTextBox({
258 mask:
"(000) 000-0000",
260 var value = this.value();
261 var valueStrip = value.replace(/_/g,
'');
262 valueStrip = valueStrip.replace(/\s/g,
'-');
263 valueStrip = valueStrip.replace(/[\(\)]/g,
'');
265 options.model.phone = valueStrip;
268 .data(
"kendoMaskedTextBox");
271 var challengeChoices = kendo.observable({
273 if ( $act ==
"settings" ) {
274 for ( $i = 0; $i < $HB_ENV[
'cu_chgqst_count']; $i++ ) {
275 print
"questionList{$i}: hcuChallengeQuestions,\n";
276 $qstId = intval($formPopulate[$i][
"security_qst"]);
277 print
"selectedQuestion{$i}: {$qstId},\n";
278 print
"response{$i}: \"{$formPopulate[$i]["security_rsp
"]}\",\n";
280 print
"confidence: \"{$mbrConfidence}\",\n";
281 print
"token: \"{$securityToken}\",\n";
284 <?php
if ($act ===
"settings") { ?>
285 gridSource:
new kendo.data.DataSource({
291 id: { type:
"number" },
292 value: { type:
"string" },
293 new: { type:
"boolean",
default:
true }
298 { field:
"new", dir:
"asc" },
299 { field:
"id", dir:
"desc" }
302 gridbind:
function() {
303 var grid = $(
"#phoneGrid").data(
"kendoGrid");
304 var data = grid.dataSource.data();
306 if (data.length >= 6) {
316 <?php
if ($act ==
"settings") { ?>
317 if (hcuCurrentQuestions.hasOwnProperty(
"answers")) {
319 for (key in hcuCurrentQuestions.answers) {
320 challengeChoices[
"selectedQuestion" + i] = key;
321 challengeChoices[
"response" + i] = hcuCurrentQuestions.answers[key];
327 kendo.bind($(
"#profile"), challengeChoices);
329 <?php
if ($act ===
"settings") { ?>
330 var grid = $(
"#phoneGrid").data(
"kendoGrid");
331 $.each(grid.columns,
function(idx, column) {
332 if (column.field ===
"value")
333 column.editor = phoneEdit;
336 $(
"#phoneGrid").on(
"click",
".removeBtn",
function() {
337 var row = $(
this).closest(
"tr");
338 var grid = $(
"#phoneGrid").data(
"kendoGrid");
339 var data = grid.dataSource.data();
345 $(
"#phoneGrid").on(
"click",
".addRow",
function() {
346 var row = $(
this).closest(
"tr");
347 var grid = $(
"#phoneGrid").data(
"kendoGrid");
348 var data = grid.dataSource.data();
355 $(
"#btnNext").click(
function() {
356 if ($.homecuValidator.validate()) {
358 $(
"#formSecurity").submit();
362 $(
"#btnUpdate").click(
function() {
364 if ( validateForm() ) {
366 action:
"challenge_save",
367 security_token: challengeChoices.token,
368 security_confidence: challengeChoices.confidence,
370 mobile: hcuPhonesList.mobile,
371 home: hcuPhonesList.home,
372 work: hcuPhonesList.work
376 request.security_phones.mobile = [];
378 var grid = $(
"#phoneGrid").data(
"kendoGrid");
379 var data = grid.dataSource.data();
380 for (var i = 0; i < data.length; i++) {
381 if (data[i].
id === -1) {
384 var value = data[i].value;
385 value = value.replace(/[\)\(]/g,
'');
386 value = value.replace(/\s/g,
'-');
387 request.security_phones.mobile.push(value);
390 request[
"security_phones"] = JSON.stringify(request[
"security_phones"]);
393 for ( var i = 0; i < <?php echo $HB_ENV['cu_chgqst_count']; ?>; i++ ) {
394 request[
"security_qst" + i] = eval(
"challengeChoices.selectedQuestion" + i );
395 request[
"security_rsp" + i] = eval(
"challengeChoices.response" + i );
400 url:
"hcuProfile.data?cu=<?php echo $HB_ENV["cu
"] ?>",
403 beforeSend:
function( xhr ) {
406 }).done(
function( data, textStatus, jqXHR ) {
407 if ( data && data.homecuErrors ) {
409 $.homecuValidator.displayMessage(data.homecuErrors, $.homecuValidator.settings.statusError);
412 if ( data && data.homecuInfo && (data.homecuInfo.message.length > 0) ) {
413 ShowStatus( data.homecuInfo.message );
415 $(
"#phoneGrid").find(
".k-dirty").remove();
419 $(
"#phoneGrid").find(
".k-dirty").remove();
422 if ( data.homecuData &&
423 data.homecuData.homecuKey &&
424 (data.homecuData.homecuKey.length > 0) ) {
425 var appInfo = JSON.stringify( { deviceKey: data.homecuData.homecuKey } );
427 <?php
if ( $HB_ENV[
"platform"] ==
"ADA" ) : ?>
428 AndroidController.notifyCommand(
"NEW_DEVICE_KEY", appInfo);
429 <?php elseif ( $HB_ENV[
"platform"] ==
"APP" ) : ?>
432 cmd:
"NEW_DEVICE_KEY",
436 window.webkit.messageHandlers.interOp.postMessage(postObject);
442 if ( $HB_ENV[
"platform"] ==
"APP" || $HB_ENV[
"platform"] ==
"ADA" ) {
443 $paramsForApps = array(
"script" =>
"ProfileSecurity" );
444 $paramsJSON = HCU_JsonEncode($paramsForApps);
446 var appInfo =
'<?php echo $paramsJSON; ?>';
448 <?php
if ( $HB_ENV[
"platform"] ==
"ADA" ) : ?>
449 AndroidController.notifyCommand(
"PROFILE_UPDATE", appInfo);
450 <?php elseif ( $HB_ENV[
"platform"] ==
"APP" ) : ?>
453 cmd:
"PROFILE_UPDATE",
457 window.webkit.messageHandlers.interOp.postMessage(postObject);
463 }).fail(
function(jqXHR, textStatus, errorThrown) {
465 $.homecuValidator.displayMessage(textStatus, $.homecuValidator.settings.statusError);
466 }).always(
function(jqXHR, textStatus, errorThrown) {
474 $.homecuValidator.setup({
475 formValidate:
"formSecurity",
476 formErrorTitle:
"<?php echo $MC->msg("Error Occurred
", HCU_DISPLAY_AS_JS) ?>" 480 reenterTip:
"<?php echo $MC->msg("Tip Re-enter Password
", HCU_DISPLAY_AS_JS); ?>",
481 confidenceTip:
"<?php echo $MC->msg("Set Config Conf Msg
", HCU_DISPLAY_AS_JS); ?>",
482 phoneTip:
"<?php echo $MC->msg("TXT Secure Access Codes
", HCU_DISPLAY_AS_JS); ?>" 487 if ( isset( $_REQUEST[
"security_curpwd"] ) && count( $errorList ) ) {
489 var error = <?php echo HCU_JsonEncode($errorList); ?>;
490 $.homecuValidator.displayMessage(error, $.homecuValidator.settings.statusError);
498 <!-- HTML STYLING -->
499 <style type=
"text/css">
500 .hcuProfileSettingsDiv {
507 .k-block > .k-header {
512 .hcu-info-margin, .hcu-error-margin {
516 .hcu-info-padding, .hcu-error-padding {
525 .hcu-container-margin {
533 #phoneGrid .k-grid-header { 537 #phoneGrid .removeBtn { 548 .k-dropdown .k-input,.k-selectbox .k-input {
553 <!-- HTML CONTENT -->
554 <div
class=
"container-fluid hcuProfileSettingsDiv" id=
"profile">
555 <div
class=
"well well-sm">
559 <h3><?php echo $MC->msg(
'Security', HCU_DISPLAY_AS_HTML); ?></h3>
562 <!-- FORM CONTENT -->
563 <form method=
"post" id=
'formSecurity' name=
'formSecurity' 564 action=
"<?php echo $HB_ENV["loginpath
"]."/{$HB_ENV[
'currentscript']}?
".$HB_ENV["cuquery
"] ?>">
566 <?php
if ($act ==
"settings") { ?>
568 <div
class=
"col-xs-12 col-md-6 hcu-container-margin">
569 <label
for=
"security_confidence">
570 <span><?php echo $MC->msg(
'Set Config Conf Label', HCU_DISPLAY_AS_HTML); ?>:</span>
571 <span
class=
"fa fa-question-circle-o" id=
"confidenceTip"></span>
574 <input type=
"text" name=
"security_confidence" 575 id=
"security_confidence" 576 class=
"k-textbox hcu-full-width" 577 placeholder=
"<?php echo $MC->msg('Set Config Conf Label', HCU_DISPLAY_AS_HTML); ?>" 579 data-bind=
"value: confidence" 580 data-required-msg=
"<?php echo $MC->msg('Set Config Enter Word', HCU_DISPLAY_AS_HTML); ?>" 586 <!--
if use mfa confidence word flag is
set,
do not show mfa questions -->
587 <?php
if (intval($HB_ENV[
'flagset3'] & $GLOBALS[
'CU3_MFA_AUTHCODE']) === 0) { ?>
589 <?php
for($i = 0; $i < $HB_ENV[
'cu_chgqst_count']; $i++) {?>
590 <div
class=
"col-xs-12 col-md-6 hcu-container-margin">
592 <label
for=
"challenge<?php echo $i; ?>">
593 <span><?php echo $MC->msg(
'Set Config Question', HCU_DISPLAY_AS_HTML) .
" " . ($i+1); ?>:</span>
596 <select name=
"challengeQuestion<?php echo $i ?>" 597 id=
"challengeQuestion<?php echo $i ?>" 598 class=
"unique_select hcu-full-width" 599 data-role=
"dropdownlist" 600 data-text-field=
"display" 601 data-value-field=
"cqid" 602 data-bind=
"source: questionList<?php echo $i; ?>, value: selectedQuestion<?php echo $i; ?>" 603 data-homecuCustomDistinct-msg=
"<?php echo $MC->msg('Challenge questions once', HCU_DISPLAY_AS_HTML); ?>" 604 homecu-distinct=
"unique_select"></select>
606 <span
class=
"k-invalid-msg" data-
for=
"challengeQuestion<?php echo $i ?>"></span>
610 <input type=
"text" name=
"challenge<?php echo $i; ?>" 611 id=
"challenge<?php echo $i; ?>" 612 class=
"k-textbox hcu-full-width" 613 placeholder=
"<?php echo $MC->msg('Set Config Response', HCU_DISPLAY_AS_HTML); ?>" 614 data-bind=
"value: response<?php echo $i; ?>" 615 data-required-msg=
"<?php echo $MC->msg('Challenge answer blank', HCU_DISPLAY_AS_HTML); ?>" 622 <div
class=
"col-xs-12 col-md-6 hcu-container-margin">
623 <label
for=
"security_phone">
624 <span><?php echo $MC->msg(
'TXT Enabled', HCU_DISPLAY_AS_HTML); ?>:</span>
625 <?php
if (intval($HB_ENV[
'flagset3'] & GetFlagsetValue(
'CU3_MFA_AUTHCODE'))) { ?>
626 <span
class=
"fa fa-question-circle-o" id=
"phoneTip"></span>
632 data-row-
template=
"gridRow" 638 { title: 'Mobile', field: 'value' } 642 events: { dataBound: gridbind }" 651 <div
class=
"col-xs-12 col-md-6 hcu-container-margin">
652 <label
for=
"security_curpwd">
653 <span><?php echo $MC->msg(
'Re-enter Password', HCU_DISPLAY_AS_HTML); ?>:</span>
654 <span
class=
"fa fa-question-circle-o" id=
"reenterTip"></span>
657 <i><?php echo $MC->msg(
"Verify Login", HCU_DISPLAY_AS_HTML); ?></i>
659 <input type=
"password" name=
"security_curpwd" 661 class=
"k-textbox hcu-full-width" 662 placeholder=
"<?php echo $MC->msg('Re-enter Password', HCU_DISPLAY_AS_HTML); ?>" 663 data-required-msg=
"<?php echo $MC->msg('Invalid login or password', HCU_DISPLAY_AS_HTML) ?>" 672 <div
class=
"hcu-template">
673 <div
class=
"hcu-edit-buttons k-state-default">
674 <?php
if ($act ==
"settings") { ?>
675 <a href=
"##" id=
"btnUpdate" class=
"k-button k-primary">
676 <i
class=
"fa fa-check fa-lg"></i><?php echo $MC->msg(
"Update", HCU_DISPLAY_AS_HTML); ?>
679 <a href=
"##" id=
"btnNext" class=
"k-button k-primary">
680 <i
class=
"fa fa-arrow-right fa-lg"></i><?php echo $MC->msg(
"Next", HCU_DISPLAY_AS_HTML); ?>
687 <script type=
"text/x-kendo-template" id=
"gridRow">
689 <tr data-uid=
"#: uid #" class=
"addRow">
690 <td
class=
"addBtn"><span
class=
"fa fa-plus-circle"></span></td>
694 <tr data-uid=
"#: uid #">
695 <td
class=
"removeBtn"><span
class=
"fa fa-minus-circle"></span></td>
707 require_once(dirname(__FILE__) .
'/../includes/hcuPostContent.i');