app/Http/Controllers/Auth/AuthenticatedSessionController.php
/**
     * Handle an incoming authentication request.
     *
     * @param  \App\Http\Requests\Auth\LoginRequest  $request
     * @return \Illuminate\Http\RedirectResponse
     */
Handle an incoming authentication request.
Handle an incoming authentication request .
public function store(Request $request)
    {
        $request->validate([
            'email'=>'required|string|email',
            'password' => 'required|string'
        ]);
        $response = Http::withHeaders([
            'Accept'=>'aplication/json',
        ])->post('http://api.codersfree.test/v1/login',[
            'email' =>  $request->email,
            'password'  => $request->password,
        ]);
        if($response->status() == 404){
            return back()->withErrors('Las credenciales no coinciden');
        }
        $service = $response->json();
        $user = User::updateOrcreate([
            'email'=>$request->email,
        ],$service['data']);
        if (!$user->accessToken) {
            $this->getAccessToken($user,$service);
        }
        Auth::login($user,$request->remember);
        return redirect()->intended(RouteServiceProvider::HOME);
    }
public function store ( Request $ request ) { $ request -> validate ( [ 'email' => 'required|string|email' , 'password' => 'required|string' ] ) ; $ response = Http :: withHeaders ( [ 'Accept' => 'aplication/json' , ] ) -> post ( 'http://api.codersfree.test/v1/login' , [ 'email' => $ request -> email , 'password' => $ request -> password , ] ) ; if ( $ response -> status ( ) == 404 ) { return back ( ) -> withErrors ( 'Las credenciales no coinciden' ) ; } $ service = $ response -> json ( ) ; $ user = User :: updateOrcreate ( [ 'email' => $ request -> email , ] , $ service [ 'data' ] ) ; if ( ! $ user -> accessToken ) { $ this -> getAccessToken ( $ user , $ service ) ; } Auth :: login ( $ user , $ request -> remember ) ; return redirect ( ) -> intended ( RouteServiceProvider :: HOME ) ; }
Handle an incoming authentication request.
Handle an incoming authentication request .
/* $request->authenticate();

        $request->session()->regenerate();

        return redirect()->intended(RouteServiceProvider::HOME); */ //return dd($response->json());