Level 16
Do you mind explaining the purpose of such approach?
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi, I create simple login page and i have some problems.
i want when user refresh webpage(step5), need input email and password one more time. It's possible?
・Controller
// show login page
public function index(Request $request) {
return view('auth.login');
}
// login
public function store(Request $request) {
$this->validate($request, [
'email' => 'required|email',
'password' => 'required',
]);
if(!auth()->attempt($request->only('email', 'password'), $request->remember)) {
return back()->with('status', 'Invalid login details');
}
return redirect()->route('dashboard');
}
・login form
<form action="{{ url('/login') }}" method="POST">
@csrf
<input type="text" name="email" placeholder="Email" value="{{ old('email') }}">
<input type="password" name="password" placeholder="choose a password" value="{{ old('password') }}">
<button type="submit">Login</button>
</form>
The easiest is to check if the user is logged in in your index method and if the user is logged in then redirect to the dashboard.
public function index(Request $request) {
if(Auth::check()) {
return redirect()->route('dashboard');
}
return view('auth.login');
}
Please or to participate in this conversation.