mardi 8 septembre 2020

how to add/override the SessionGurad?

I want to override one method in laravel 5.4

src/Illuminate/Auth/SessionGuard.php

public function id()
{
    if ($this->loggedOut) {
        return;
    }

    return $this->user()
                ? $this->user()->getAuthIdentifier()
                : $this->session->get($this->getName());
}

change to this

public function id()
{
    if ($this->loggedOut) {
        return;
    }

    return $this->user()
                ? $this->user()->user_id
                : $this->session->get($this->getName());
}

i am just want to change $this->user()->getAuthIdentifier() to this $this->user()->user_id

why i am doing this is because i am getting user from a external api and i don't want to use database i can do this by going in the framework and change there but i want to know the best way to override the default laravel authentication



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire