Changing laravel remember_token field to something else

In my project I use Auth login, everything works fine until I try to log out:

  Auth::logout();

I use the custom field name herrinerToken instead of the remember_token default value. In my /user.php model, I edited the getRememberToken () function:

 public function getRememberTokenName()
{
    return 'herrinerToken';
}

when I try to log out, I get a message:

SQLSTATE [42S22]: Column not found: 1054 Unknown column 'remember_token' in 'field list' (SQL: update gebruikersset herrinerToken= a3eYy1IIbX1FfPhPgmYNTNLwkE7A43vgqwpSU2B5b3EFNHl0ayYF1vUSGCbc remember_token= a3eYy1IIbX1FfPhPgmYNTNLwkE7A43vgqwpSU2B5b3EFNHl0ayYF1vUSGCbc where id= 6 )

So it looks like it is trying to update tu and remember_token and herrinerToken, but I want to update the herinner_token field. What do I need to configure only to update the herrinerToken field, and not the remember_token field?

+4
source share
2 answers

Add a column herrinerTokeninstead of a column remember_tokento your users table (or equivalent).

You should use the following snippet with this:

public function getRememberToken()
{
    return $this->herrinerToken;
}

public function setRememberToken($value)
{
    $this->herrinerToken = $value;
}

public function getRememberTokenName()
{
    return 'herrinerToken';
}
+8
source

. , "remember_token" DatabaseUserProvider - , , Laravel - "remember_token", Authentication Database.

Eloquent auth. , Eloquent - .

app/config/auth.php, Eloquent, - :

return array(

    /*
    |--------------------------------------------------------------------------
    | Default Authentication Driver
    |--------------------------------------------------------------------------
    |
    | This option controls the authentication driver that will be utilized.
    | This driver manages the retrieval and authentication of the users
    | attempting to get access to protected areas of your application.
    |
    | Supported: "database", "eloquent"
    |
    */

    'driver' => 'eloquent',
+1

Source: https://habr.com/ru/post/1540904/


All Articles