Skip to content
Snippets Groups Projects
Commit baac60b7 authored by Jared Hancock's avatar Jared Hancock
Browse files

Fixup user search using directory backends

parent 9faaeecf
Branches
Tags
No related merge requests found
...@@ -464,7 +464,7 @@ class TicketsAjaxAPI extends AjaxController { ...@@ -464,7 +464,7 @@ class TicketsAjaxAPI extends AjaxController {
Http::response(404, 'No such ticket'); Http::response(404, 'No such ticket');
elseif (!$bk || !$id) elseif (!$bk || !$id)
Http::response(422, 'Backend and user id required'); Http::response(422, 'Backend and user id required');
elseif (!($backend = AuthenticationBackend::getBackend($bk))) elseif (!($backend = StaffAuthenticationBackend::getBackend($bk)))
Http::response(404, 'User not found'); Http::response(404, 'User not found');
$user_info = $backend->lookup($id); $user_info = $backend->lookup($id);
......
...@@ -51,7 +51,7 @@ class UsersAjaxAPI extends AjaxController { ...@@ -51,7 +51,7 @@ class UsersAjaxAPI extends AjaxController {
} }
} }
foreach (AuthenticationBackend::searchUsers($_REQUEST['q']) as $u) { foreach (StaffAuthenticationBackend::searchUsers($_REQUEST['q']) as $u) {
$name = "{$u['first']} {$u['last']}"; $name = "{$u['first']} {$u['last']}";
$users[] = array('email' => $u['email'], 'name'=>$name, $users[] = array('email' => $u['email'], 'name'=>$name,
'info' => "{$u['email']} - $name (remote)", 'info' => "{$u['email']} - $name (remote)",
...@@ -122,7 +122,7 @@ class UsersAjaxAPI extends AjaxController { ...@@ -122,7 +122,7 @@ class UsersAjaxAPI extends AjaxController {
Http::response(403, 'Login Required'); Http::response(403, 'Login Required');
elseif (!$bk || !$id) elseif (!$bk || !$id)
Http::response(422, 'Backend and user id required'); Http::response(422, 'Backend and user id required');
elseif (!($backend = AuthenticationBackend::getBackend($bk))) elseif (!($backend = StaffAuthenticationBackend::getBackend($bk)))
Http::response(404, 'User not found'); Http::response(404, 'User not found');
$user_info = $backend->lookup($id); $user_info = $backend->lookup($id);
...@@ -177,7 +177,7 @@ class UsersAjaxAPI extends AjaxController { ...@@ -177,7 +177,7 @@ class UsersAjaxAPI extends AjaxController {
Http::response(400, 'Query argument is required'); Http::response(400, 'Query argument is required');
$users = array(); $users = array();
foreach (AuthenticationBackend::allRegistered() as $ab) { foreach (StaffAuthenticationBackend::allRegistered() as $ab) {
if (!$ab instanceof AuthDirectorySearch) if (!$ab instanceof AuthDirectorySearch)
continue; continue;
......
...@@ -156,7 +156,7 @@ abstract class AuthenticationBackend { ...@@ -156,7 +156,7 @@ abstract class AuthenticationBackend {
static function searchUsers($query) { static function searchUsers($query) {
$users = array(); $users = array();
foreach (static::$registry as $bk) { foreach (static::allRegistered() as $bk) {
if ($bk instanceof AuthDirectorySearch) { if ($bk instanceof AuthDirectorySearch) {
$users += $bk->search($query); $users += $bk->search($query);
} }
...@@ -631,7 +631,9 @@ StaffAuthenticationBackend::register(osTicketAuthentication); ...@@ -631,7 +631,9 @@ StaffAuthenticationBackend::register(osTicketAuthentication);
class PasswordResetTokenBackend extends StaffAuthenticationBackend { class PasswordResetTokenBackend extends StaffAuthenticationBackend {
static $id = "pwreset.staff"; static $id = "pwreset.staff";
function authenticate($username, $password) {} function supportsAuthentication() {
return false;
}
function signOn($errors=array()) { function signOn($errors=array()) {
if (!isset($_POST['userid']) || !isset($_POST['token'])) if (!isset($_POST['userid']) || !isset($_POST['token']))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment