ci->currentUser; // FOR DATABASE QUERY $access_token = $args['access_token']; if (DB::table('public_keys') ->where('UserID', 1) ->where('Key', '=', $access_token) ->exists()) { $user_id = $args['user_id']; $session_id = $args['session_id']; $session_file = file_get_contents("../app/sessions/" . $session_id); $session_user_id = unserialize(substr($session_file, strpos($session_file, "account|") + 8))["current_user_id"]; if ($session_user_id === $user_id) { return $response->withStatus(200); } else { throw new NotFoundException(); } } else { throw new NotFoundException(); // IT'S A FORBIDDEN EXCEPTION BUT IT'S SECRET! PSSSHT } } public function getUsername(Request $request, Response $response, $args) { $currentUser = $this->ci->currentUser; // FOR DATABASE QUERY $access_token = $args['access_token']; if (DB::table('public_keys') ->where('UserID', 1) ->where('Key', '=', $access_token) ->exists()) { $user_id = $args['user_id']; $username =(DB::table('users') ->where('id', $user_id) ->value('user_name')); $response->write($username); } else { throw new NotFoundException(); // IT'S A FORBIDDEN EXCEPTION BUT IT'S SECRET! PSSSHT } } }