How to customize Laravel authentication for external api token

0

I'm doing an application that is just the "front", the whole backend part (authentication, DB, etc) is done by another application, I access everything via REST.

The login for example, I send via REST the email and the password, and it returns me the token (which I saved in the session). The question is: I wanted to be able to use, for example, the directives of the blade @guest and @auth to mount my views , and make some routes dependent on this authentication too, as I would do to make it part of the laravel equal to auth default?

namespace App\Services;


use GuzzleHttp\Client;

class ApiService
{
    private $client;

    public function __construct()
    {
        $this->client = new Client([
          'base_uri'=>env('API_HOST','http://localhost:8080'),
          'headers'=>[
            'token'=>session('token')
          ]
        ]);
    }

    public function get(string $uri,array $query)
    {
        return $this->client->get($uri,[
          'query'=>$query
        ]);
    }

    public function post(string $uri,array $formdata)
    {

        return $this->client->post($uri,[
          'form_params'=>$formdata
        ]);
    }
    
asked by anonymous 29.10.2018 / 23:02

0 answers