Laravel auth check login
use Illuminate\Support\Facades\Auth;
if (Auth::check()) {
// The user is logged in...
}
use Auth;
//find auth
function __construct()
{
$this->middleware('auth');
}
//end find auth
Laravel auth check login
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
class LoginController extends Controller
{
/**
* Handle an authentication attempt.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function authenticate(Request $request)
{
$credentials = $request->validate([
'email' => ['required', 'email'],
'password' => ['required'],
]);
if (Auth::attempt($credentials)) {
$request->session()->regenerate();
return redirect()->intended('dashboard');
}
return back()->withErrors([
'email' => 'The provided credentials do not match our records.',
]);
}
}
0 comments:
Post a Comment
Thanks