* @author Brady Miller * @copyright Copyright (c) 2019-2021 Jerry Padgett * @copyright Copyright (c) 2019 Brady Miller * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3 */ $ignoreAuth_onsite_portal = $ignoreAuth = false; // Will start the (patient) portal OpenEMR session/cookie. require_once(dirname(__FILE__) . "/../../src/Common/Session/SessionUtil.php"); OpenEMR\Common\Session\SessionUtil::portalSessionStart(); $landingpage = "./../index.php?site=" . urlencode($_SESSION['site_id']); // kick out if patient not authenticated if (isset($_SESSION['pid']) && isset($_SESSION['patient_portal_onsite_two'])) { $ignoreAuth_onsite_portal = true; } else { OpenEMR\Common\Session\SessionUtil::portalSessionCookieDestroy(); header('Location: ' . $landingpage . '&w'); exit; } require_once(dirname(__FILE__) . '/../../interface/globals.php'); require_once(dirname(__FILE__) . "/../lib/appsql.class.php"); use OpenEMR\Common\Auth\AuthHash; use OpenEMR\Common\Csrf\CsrfUtils; use OpenEMR\Core\Header; $logit = new ApplicationTable(); //exit if portal is turned off if (!(isset($GLOBALS['portal_onsite_two_enable'])) || !($GLOBALS['portal_onsite_two_enable'])) { echo xlt('Patient Portal is turned off'); exit; } if (!empty($_POST)) { if (!CsrfUtils::verifyCsrfToken($_POST["csrf_token_form"], "portal_index_reset")) { CsrfUtils::csrfNotVerified(); } } $_SESSION['credentials_update'] = 1; DEFINE("TBL_PAT_ACC_ON", "patient_access_onsite"); DEFINE("COL_ID", "id"); DEFINE("COL_PID", "pid"); DEFINE("COL_POR_PWD", "portal_pwd"); DEFINE("COL_POR_USER", "portal_username"); DEFINE("COL_POR_LOGINUSER", "portal_login_username"); DEFINE("COL_POR_PWD_STAT", "portal_pwd_status"); $sql = "SELECT " . implode(",", array(COL_ID, COL_PID, COL_POR_PWD, COL_POR_USER, COL_POR_LOGINUSER, COL_POR_PWD_STAT)) . " FROM " . TBL_PAT_ACC_ON . " WHERE pid = ?"; $auth = privQuery($sql, array($_SESSION['pid'])); $valid = ((!empty(trim($_POST['uname']))) && (!empty(trim($_POST['login_uname']))) && (!empty(trim($_POST['pass_current']))) && (!empty(trim($_POST['pass_new']))) && (trim($_POST['uname']) == $auth[COL_POR_USER]) && (AuthHash::passwordVerify(trim($_POST['pass_current']), $auth[COL_POR_PWD]))); if (isset($_POST['submit'])) { if (!$valid) { $errmsg = xlt("Invalid Current Credentials Error.") . xlt("Unknown."); $logit->portalLog('Credential update attempt', '', ($_POST['uname'] . ':unknown'), '', '0'); die($errmsg); } $new_hash = (new AuthHash('auth'))->passwordHash(trim($_POST['pass_new'])); if (empty($new_hash)) { // Something is seriously wrong error_log('OpenEMR Error : OpenEMR is not working because unable to create a hash.'); die("OpenEMR Error : OpenEMR is not working because unable to create a hash."); } $sqlUpdatePwd = " UPDATE " . TBL_PAT_ACC_ON . " SET " . COL_POR_PWD . "=?, " . COL_POR_LOGINUSER . "=?" . " WHERE " . COL_ID . "=?"; privStatement($sqlUpdatePwd, array( $new_hash, $_POST['login_uname'], $auth[COL_ID] )); } ?> <?php echo xlt('Change Portal Credentials'); ?> dlgclose();\n"; } ?>
" />