I am facing this issues with laravel 5.2, I am using multiple auth with different tables ( admins , users ) with admin section login it works correctly , with user login it gives me this error ?
Add configured in your app/auth.php config file.
like
return [ 'defaults' => [ 'guard' => 'admin', 'passwords' => 'admin',], 'guards' => [ 'admin' => [ 'driver' => 'session', 'provider' => 'admin', ]], 'providers' => [ 'admin' => [ 'driver' => 'eloquent', 'model' => App\User::class, ],], 'passwords' => [ 'admin' => [ 'provider' => 'admin', 'email' => 'auth.emails.password', 'table' => 'password_resets', 'expire' => 60,],] ]
Related
after updating my Laravel and Adldap2 to version 6.0,i'm receiving this error when i'm trying to authenticate,
**
The 'email' key is missing from the given credentials array
**
what is the reason behind that ?
i haven't changed anything in my LoginController or Auth.php or anywhere else,
my config/auth.php
<?php
return [
'defaults' => [
'guard' => 'web',
'passwords' => 'users',
],
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
'api' => [
'driver' => 'token',
'provider' => 'users',
],
],
'providers' => [
'users' => [
'driver' => 'ldap', //'eloquent',
'model' => App\User::class,
'table' => 'users',
],
],
'passwords' => [
'users' => [
'provider' => 'users',
'table' => 'password_resets',
'expire' => 60,
],
],
];
After upgrading to Laravel 6 and adldap 6 You need to republish config files.
https://github.com/Adldap2/Adldap2-Laravel/blob/master/docs/upgrading.md
I make 2 guards 1. For admin and 2. for student. Now when i click on my button to show the login form i always caught that error that Auth guard [web] is not defined.Now how i solve this.
here is my config/auth.php
'defaults' => [
'guard' => 'web',
'passwords' => 'users',
],
'guards' => [
'admin' => [
'driver' => 'session',
'provider' => 'admins',
],
'student' => [
'driver' => 'session',
'provider' => 'student',
],
'api' => [
'driver' => 'token',
'provider' => 'users',
'hash' => false,
],
],
'providers' => [
'admins' => [
'driver' => 'eloquent',
'model' => App\Admin::class,
],
'students' => [
'driver' => 'eloquent',
'model' => App\Student::class,
],
// 'users' => [
// 'driver' => 'database',
// 'table' => 'users',
// ],
],
I am trying login the admin using admin guard.Please help me to solve that and i dont use default User.php model.
That's because you're removing web guard from the application.
Just change your default guard from web to your new guard.
'defaults' => [
'guard' => 'admins',
'passwords' => 'users',
],
I have read other questions about my error so I re-checked my code and didn't found any typo mistake ,
Error
Symfony \ Component \ Debug \ Exception \ FatalThrowableError
(E_RECOVERABLE_ERROR) Argument 2 passed to
Illuminate\Auth\SessionGuard::__construct() must implement interface
Illuminate\Contracts\Auth\UserProvider, null given, called in
\vendor\laravel\framework\src\Illuminate\Auth\AuthManager.php on line
125
Auth.php
return [
'defaults' => [
'guard' => 'web',
'passwords' => 'users',
],
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
'api' => [
'driver' => 'token',
'provider' => 'users',
'hash' => false,
],
'admin' => [
'driver' => 'session',
'provider' => 'admin',
],
'user' => [
'driver' => 'session',
'provider' => 'user',
],
'company' => [
'driver' => 'session',
'provider' => 'company',
],
'employee' => [
'driver' => 'session',
'provider' => 'employee',
],
],
'providers' => [
'admin' => [
'driver' => 'eloquent',
'model' => App\Admin::class,
],
'company' => [
'driver' => 'eloquent',
'model' => App\Model\Employee::class,
],
'employee' => [
'driver' => 'eloquent',
'model' => App\Model\Employee::class,
],
],
];
You need to define the provider for your new guard otherwise it will throw the error. Your provider should also be spelt 'admins' as you are referencing the particular migration table for admins
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => App\User::class,
],
'admins' => [
'driver' => 'eloquent',
'model' => App\Admin::class,
],
],
Everything was fine I was just called old default user auth in controller which I was modified in old project and now I am installed new project and then move all of files except user.php default model
$companyAuth = auth()->guard('user'); //called wrong default
$companyAuth = auth()->guard('employee'); //now working fine
I have 2 guard in Laravel 5.3: web and admin.
I need to convert Auth::guard('web') to Auth::guard('user') in Laravel 5.3?
How to convert web to user?
After change in auth.php:
'defaults' => [
'guard' => 'user',
'passwords' => 'users',
],
'guards' => [
'user' => [
'driver' => 'session',
'provider' => 'users',
],
'admin' => [
'driver' => 'session',
'provider' => 'admin',
],
'api' => [
'driver' => 'token',
'provider' => 'users',
],
],
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => App\User::class,
],
'admin' => [
'driver' => 'eloquent',
'model' => App\Admin::class,
],
],
'passwords' => [
'users' => [
'provider' => 'users',
'table' => 'password_resets',
'expire' => 60,
],
],
You should open config/auth.php
There you should update web to user on guards array and defaults array also in providers and passwords array and you will have guard('user').
I use Laravel 5.2 and I need to use multi table authentication. I read from this link Can anyone explain Laravel 5.2 Multi Auth with example
I modified config/auth.php
'guards' => [
'user' =>[
'driver' => 'session',
'provider' => 'user',
],
'admin' => [
'driver' => 'session',
'provider' => 'admin',
],
],
//User Providers
'providers' => [
'user' => [
'driver' => 'eloquent',
'model' => App\User::class,
],
'admin' => [
'driver' => 'eloquent',
'model' => App\Admin::class,
]
],
//Resetting Password
'passwords' => [
'user' => [
'provider' => 'user',
'email' => 'auth.emails.password',
'table' => 'password_resets',
'expire' => 60,
],
'admin' => [
'provider' => 'admin',
'email' => 'auth.emails.password',
'table' => 'password_resets',
'expire' => 60,
],
],
Here is part of the controller for login (post method)
$admindata = array(
'email' => Input::get('email'),
'password' => Input::get('password')
);
if (Auth::attempt($admindata)) {
echo 'SUCCESS!';
} else {
$admin = Auth::admin();
return Redirect::to('/b');
}
But I got this error
ErrorException in AuthManager.php line 288: call_user_func_array()
expects parameter 1 to be a valid callback, class
'Illuminate\Auth\SessionGuard' does not have a method 'admin'
It looks like the error is on Auth::attempt(). How to solve this error?
I believe the error is not in attempt method but here:
$admin = Auth::admin();
You try to run here admin method and obviously there is no such method in Illuminate\Auth\SessionGuard class.