lockoutTime = config('auth.lockout.time'); $this->maxLoginAttempts = config('auth.lockout.attempts'); $this->auth = Container::getInstance()->make(AuthManager::class); } /** * Get the failed login response instance. * * @throws \Pterodactyl\Exceptions\DisplayException */ protected function sendFailedLoginResponse(Request $request, Authenticatable $user = null, string $message = null) { $this->incrementLoginAttempts($request); $this->fireFailedLoginEvent($user, [ $this->getField($request->input('user')) => $request->input('user'), ]); if ($request->route()->named('auth.login-checkpoint')) { throw new DisplayException($message ?? trans('auth.two_factor.checkpoint_failed')); } throw new DisplayException(trans('auth.failed')); } /** * Send the response after the user was authenticated. */ protected function sendLoginResponse(User $user, Request $request): JsonResponse { $request->session()->remove('auth_confirmation_token'); $request->session()->regenerate(); $this->clearLoginAttempts($request); $this->auth->guard()->login($user, true); return new JsonResponse([ 'data' => [ 'complete' => true, 'intended' => $this->redirectPath(), 'user' => $user->toVueObject(), ], ]); } /** * Determine if the user is logging in using an email or username,. */ protected function getField(string $input = null): string { return ($input && str_contains($input, '@')) ? 'email' : 'username'; } /** * Fire a failed login event. */ protected function fireFailedLoginEvent(Authenticatable $user = null, array $credentials = []) { event(new Failed('auth', $user, $credentials)); } }