Untitled
Never
<?php namespace App\Http\Controllers\API; use App\Models\Server; use App\Helpers\HelperAccessToken; use App\Http\Controllers\Controller; use App\Http\Requests\API\GameServerAuthRequest; use App\Exceptions\GameServerApiException; use Illuminate\Http\Request; use Illuminate\Http\JsonResponse; use Illuminate\Support\Facades\Hash; use Illuminate\Support\Facades\Response; class GameServerAuthController extends Controller { /** * Handle a authorization the game server request to the application. * * @param GameServerAuthRequest $request * @return JsonResponse * @throws GameServerApiException */ public function __invoke(GameServerAuthRequest $request): JsonResponse { $server = $this->getGameServer($request); $authToken = $request->input('auth_token'); if ($this->attemptGameServer($server, $authToken)) { return $this->sendResponseOnAuth($server); } return $this->sendResponseOnFailedAuth(); } /** * Gets an instance of game server model based on request. * * @param Request $request * @return Server * @throws GameServerApiException */ protected function getGameServer(Request $request): Server { return Server::where([ ['ip', $request->ip()], ['port', $request->input('port')] ])->firstOr(function () { throw new GameServerApiException('Game server not found.', JsonResponse::HTTP_NOT_FOUND); }); } /** * Attempt to auth the game server into the application. * * @param Server $server * @param string $authToken * @return bool */ protected function attemptGameServer(Server $server, string $authToken): bool { return Hash::check($authToken, $server->auth_token); } /** * Send the response after the game server was authorized. * * @param Server $server * @return JsonResponse */ protected function sendResponseOnAuth(Server $server): JsonResponse { $server->access_token()->updateOrCreate( ['server_id' => $server->id], [ 'token' => HelperAccessToken::generateToken(), 'expires_in' => HelperAccessToken::createExpiresDate() ] ); $server->update(['active' => true]); return Response::json([ 'success' => true, 'access_token' => $server->access_token ], JsonResponse::HTTP_OK); } /** * Gets an instance of response with an error on authorization. * * @throws GameServerApiException */ protected function sendResponseOnFailedAuth() { return throw new GameServerApiException('Game server is unauthorized',JsonResponse::HTTP_UNAUTHORIZED); } }
Raw Text
-
No Deposit Bonus
8 min ago
-
Hottie get hardcore fucked by grandpa on the couch and she swallows his jizz
12 min ago
-
Adult Telegram Channels
12 min ago
-
Untitled
29 min ago
-
LOAN4K. Fucking for a new apartment for Mia Evans
43 min ago
-
Untitled
47 min ago
-
The hairdresser settled the conflict due to a bad haircut, and then licked the sperm from her stomac
1 hour ago
-
The Genius Wave
1 hour ago
-
Untitled
1 hour ago
-
18 year old girl lets her friend fuck her in the ass. Her tight ass is awesome!!
1 hour ago