<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;

class AuthController extends Controller
{
    
    // public function login(Request $request)
    // {
    //     if (Auth::attempt($credentials)) {
    //         $request->session()->regenerate(); 

    //         return redirect()->intended('/');
    //     }

    //     return back()->withErrors([...]);
    // }
    /**
     * Log the user out of the application.
     */
    public function logout(Request $request)
    {
        // 1. Log the user out
        Auth::logout();
    
        // 2. Invalidate the user's session
        $request->session()->invalidate();
    
        // 3. Regenerate the CSRF token for security
        $request->session()->regenerateToken();
    
        // 4. Redirect them back to the login page
        return redirect('/login');
    }
}