middleware('nova.guest:'.config('nova.guard'))->except('logout'); } /** * Show the application's login form. * * @return \Inertia\Response|\Symfony\Component\HttpFoundation\Response */ public function showLoginForm() { return view('vendor.nova.pages.login'); } /** * The user has been authenticated. * * @param mixed $user * @return mixed */ protected function authenticated(Request $request, $user) { $redirect = redirect()->intended($this->redirectPath()); return $request->wantsJson() ? new JsonResponse([ 'redirect' => $redirect->getTargetUrl(), ], 200) : $redirect; } /** * Log the user out of the application. * * @return \Illuminate\Http\RedirectResponse */ public function logout(Request $request) { $this->guard()->logout(); $request->session()->invalidate(); return redirect()->intended($this->redirectPath()); } /** * Get the post register / login redirect path. * * @return string */ public function redirectPath() { return Nova::url(Nova::$initialPath); } /** * Get the guard to be used during authentication. * * @return \Illuminate\Contracts\Auth\StatefulGuard */ protected function guard() { return Auth::guard(config('nova.guard')); } /** * Get the login username to be used by the controller. */ public function username(): string { return 'username'; } /** * Validate the user login request. * * @return void * * @throws \Illuminate\Validation\ValidationException */ protected function validateLogin(Request $request) { $request->validate([ $this->username() => ['required', 'string', 'max:250', 'exists:users,username'], 'password' => ['required', 'string', 'max:250'], ]); } }