Skip to content

Commit

Permalink
authx - If using auto-login, then use a redirect to hide the `?_authx…
Browse files Browse the repository at this point in the history
…=...` gunk
  • Loading branch information
totten committed Feb 23, 2021
1 parent 942f4d0 commit ba87ea5
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion ext/authx/authx.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@
}
elseif (!empty($params['_authxSes'])) {
(new \Civi\Authx\Authenticator('auto'))->auth($e, $params['_authx'], TRUE);
_authx_redact(['_authx', '_authxSes']);
if ($_SERVER['REQUEST_METHOD'] === 'GET') {
_authx_reload(implode('/', $e->args), $_SERVER['QUERY_STRING']);
}
else {
_authx_redact(['_authx', '_authxSes']);
}
}
else {
(new \Civi\Authx\Authenticator('param'))->auth($e, $params['_authx']);
Expand Down Expand Up @@ -52,6 +57,23 @@ function _authx_redact(array $keys) {
}
}

/**
* Reload the current page-view.
*
* @param string $route
* @param string $queryString
*/
function _authx_reload($route, $queryString) {
parse_str($queryString, $query);
foreach (array_keys($query) as $key) {
if (CRM_Utils_String::startsWith($key, '_authx')) {
unset($query[$key]);
}
}
$url = CRM_Utils_System::url($route, $query, TRUE, NULL, FALSE, CRM_Core_Config::singleton()->userSystem->isFrontEndPage());
CRM_Utils_System::redirect($url);
}

/**
* Implements hook_civicrm_config().
*
Expand Down

0 comments on commit ba87ea5

Please sign in to comment.