laravel 5.3 authentication with jenssegers-mongodb
Add package https://github.com/jenssegers/Laravel-MongoDB-Session to laravel
Install using composer:
composer require jenssegers/mongodb-session
Change the session driver in app/config/session.php to mongodb:
'driver' => 'mongodb',
Optional: change the connection to a connection using the mongodb driver from app/config/database.php:
'connection' => 'mongodb',
config/app.php
'providers' => [ Jenssegers\Mongodb\MongodbServiceProvider::class, Jenssegers\Mongodb\Session\SessionServiceProvider::class, Jenssegers\Mongodb\Auth\PasswordResetServiceProvider::class,
User model
namespace App; use Illuminate\Notifications\Notifiable; use Jenssegers\Mongodb\Eloquent\Model as Eloquent; use Illuminate\Auth\Authenticatable; use Illuminate\Auth\Passwords\CanResetPassword; use Illuminate\Foundation\Auth\Access\Authorizable; use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract; use Illuminate\Contracts\Auth\Access\Authorizable as AuthorizableContract; use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract; class User extends Eloquent implements AuthenticatableContract, AuthorizableContract, CanResetPasswordContract { use Authenticatable, Authorizable, CanResetPassword; use Notifiable; /** * The database table used by the model. * * @var string */ protected $collection = 'users'; /** * The database primary key value. * * @var string */ protected $primaryKey = '_id'; /** * The attributes that are mass assignable. * * @var array */ protected $fillable = [ 'name', 'email', 'password', ]; /** * The attributes that should be hidden for arrays. * * @var array */ protected $hidden = [ 'password', 'remember_token', ]; }
and try to register/login