/** * @param $id * @param HttpFoundation\Request $request * @return HttpFoundation\JsonResponse|HttpFoundation\Response */ public function getIndex($id, HttpFoundation\Request $request) { $this->log->addDebug(print_r($request, true), ['namespace' => 'HackTheDinos\\Controllers\\User', 'method' => 'getIndex', 'type' => 'request']); $count = $request->get('count', 10); $count = $count > 100 ? 100 : $count; //Cap the max number of returned results $start = $request->get('start', 0); $start = $start < 0 ? 0 : $start; //Prevent negatives on the start value $users = is_null($id) ? $this->repo->getAll([], $count, $start) : $this->repo->getById($id); $this->log->addInfo('Found Users', ['namespace' => 'HackTheDinos\\Controllers\\User', 'method' => 'getIndex', 'users' => $users]); return new HttpFoundation\JsonResponse($users, 200); }
/** * @param string $username * @return ARRAY the associated "user_id" and optional "scope" values * This function MUST return FALSE if the requested user does not exist or is * invalid. "scope" is a space-separated list of restricted scopes. * @code * return array( * "user_id" => USER_ID, // REQUIRED user_id to be stored with the authorization code or access token * "scope" => SCOPE // OPTIONAL space-separated list of restricted scopes * ); * @endcode */ public function getUserDetails($username) { $users = $this->usersRepo->getAll(['email' => $username], 1); return empty($users) ? false : ['user_id' => $users[0]->id, 'scope' => 'user']; }