/** * * Updates the login information about a user * @param str $party_id - party id of the user * @param str $login_id - new user login id * @param str $password - new password */ function users_update_login($party_id, $login_id, $password) { $exists = user_get_login($login_id); if (!empty($exists) && $exists['PARTY_ID'] != $party_id) { throw new RuntimeException(sprintf('There is user with the same login: %s', $login_id)); } $query = "UPDATE user_login\n\t\t\t SET USER_LOGIN_ID = '" . esc($login_id) . "', CURRENT_PASSWORD='******', LAST_UPDATED_STAMP = '" . now() . "', LAST_UPDATED_TX_STAMP = NOW()\n\t\t\t WHERE PARTY_ID = '" . esc($party_id) . "'\n\t\t\t LIMIT 1"; db_query($query); }
// otherwise threat as a normal user $roles = roles_get_party_role($_SESSION['user']['PARTY_ID']); if ($roles['ROLE_TYPE_ID'] == ROLE_ADMIN) { $_SESSION['user']['IS_ADMIN'] = true; $redirect_url = '/users/index'; } else { $_SESSION['user']['IS_ADMIN'] = false; $redirect_url = '/dashboard/dashboard'; } if (isset($_POST['REMEMBER_ME'])) { setcookie('RememberUser', $admin['PARTY_ID'], time() + 60 * 60 * 24 * 365, '/'); } if (trim($_POST['REFERAL']) != '') { $redirect_url = $_POST['REFERAL']; exit; } $_SESSION['user']['LAST_ACTION'] = time(); user_login_history_add($_POST['USER_LOGIN_ID'], true, $_SESSION['user']['PARTY_ID']); header(sprintf("location: %s", $redirect_url)); exit; } else { $errors[] = 'Invalid username and/or password'; user_failed_login($_POST['USER_LOGIN_ID']); $party = user_get_login($_POST['USER_LOGIN_ID']); $party_id = !empty($party['PARTY_ID']) ? $party['PARTY_ID'] : ''; user_login_history_add($_POST['USER_LOGIN_ID'], 0, $party_id); } } } $link = THEME . 'index.php'; require_once $link;