Coder Social home page Coder Social logo

laravel-multiauth's People

Contributors

francistm avatar sarav-s avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

laravel-multiauth's Issues

Every Auth::user() make a query

Hi

Every time I use Auth::user('admin') new query i made:

select * from admins where admins.id = '6' limit 1

5xAuth::user('admin') = 5 queries :(

I found that it should be saved in $this->user in Guard but it's not.

reg.
GM

Config NULL

Hello, I modified the routes and the configs in previous post, then modified the authcontroller, after that I create a view file for test, but failed(/user/login):
ErrorException in Manager.php line 212:array_keys() expects parameter 1 to be array, null given
in Manager.php line 212
at HandleExceptions->handleError('2', 'array_keys() expects parameter 1 to be array, null given', '/Users/SkyAo/Documents/Coding/PHP/TextbookSystem/vendor/sarav/laravel-multiauth/src/Manager.php', '212', array('config' => null, 'default' => null))
at array_keys(null) in Manager.php line 212
at Manager->setDefaultConfig() in AuthManager.php line 35
at AuthManager->getDefaultDriver() in Manager.php line 71
at Manager->driver() in MultiauthServiceProvider.php line 44

Cant config password_reset table

Hi All!

I can't make work the password reset functionability for admins.
As you may see below it attempts to delete a password reset row from an empty table (password_reset)

I always get:

SQLSTATE[42000]: Syntax error or access violation: 1103 Incorrect table name '' (SQL: delete from `` where `email` = [email protected])

This is my configuration file

return [
  'multi' => [
    'user' => [
        'driver' => 'eloquent',
        'model'  => App\User::class,
        'table'  => 'users'
    ],
    'admin' => [ 
        'driver' => 'eloquent',
        'model'  => App\Admin::class,
        'table'  => 'admins',
        'password' => [
          'email' => 'emails.password',
          'table' => 'password_resets',
          'expire' => 60,
        ],
    ],
 ],
 ],

thanks in advance

class 'Sarav\Multiauth\Guard' does not have a method 'guard'

Hi Sarav,

I'm trying to get this multiauth working. I've followed the instructions in your article. But when I try to access \user\login I'm getting this error.

ErrorException in Manager.php line 197:
call_user_func_array() expects parameter 1 to be a valid callback, class 'Sarav\Multiauth\Guard' does not have a method 'guard'

Can you please help me resolve this?

Thanks,

Compatible with L5.5?

I was preparing for a small project and I'd like to know if this is compatible with current Laravel release version 5.5. Because in the Readme, it says its only for 5.1.*

Password reset always checking users from users table

I have implemented two authentication tables admin and users. It works fine for login system.
But password reset is always checking users from users table.

'multi' => [
'user' => [
'driver' => 'eloquent',
'model' => App\User::class,
'table' => 'users'
],
'admin' => [
'driver' => 'eloquent',
'model' => App\Admin::class,
'table' => 'admins'
]
],

Support for LDAP ??

Support for LDAP ??

auth.php

return ['multi' => [
    'user' => [
        'driver' => 'ldap',
        'model'  => App\User::class,
        'table'  => 'users'
    ],
    'admin' => [
        'driver' => 'eloquent',
        'model'  => App\Admin::class,
        'table'  => 'admins'
    ]
 ],
Route::get('user', function () {

    if(\Auth::attempt("user", ['email' => '[email protected]', 'password' => 'password']))
    {
        echo "ok!!";
    }else{

        echo "Noooo";
    }   

    return view('welcome');
});

Argument 1 passed to Sarav\Multiauth\Guard::__construct() must implement interface Illuminate\Contracts\Auth\UserProvider, instance of Illuminate\Auth\Guard given, called in /var/www/html/multi/vendor/sarav/laravel-multiauth/src/AuthManager.php on line 63 and defined

One work, other not

Hello, I have a little problem, what should I do when the only work the first element and the second is ignored, so when I want for YouTuber account to log in and is specified as the first in a multi [...] and logs all right, but when used authority account, then it gets passes without errors, but Auth: user () not set

return [
'multi' => [
    'authority' => [
        'driver' => 'eloquent',
        'model'  => \Inori\Authority::class, // Model Class
        'table'  => 'authority' //authority table
    ],
    'youtuber' => [
        'driver' => 'eloquent',
        'model'  => \Inori\Youtuber::class, // Model Class
        'table'  => 'youtuber' // youtuber table
    ]
 ],
 'password' => [
       'email' => 'emails.password',
       'table' => 'password_resets',
       'expire' => 60,
  ]
 ];

Google translate ftw...

Middleware not working

I created login related Issue about 3 days ago and got helped by author, but laravel default Authenticate Middleware not working, so I created one but it not working, it redirect me to the login page. I need full attention of author to solve my problem because without it my project not moving forword :(

I also share my code in stackoverflow, I think author know me well.
http://stackoverflow.com/questions/39248250/multi-auth-not-working-in-laravel-5-1

This is my custom Middleware

auth = $auth->with('user'); } /** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { if ($this->auth->guest('user')) { if ($request->ajax()) { return response('Unauthorized.', 401); } else { return redirect()->guest('login'); } } return $next($request); } ``` } And this is my **route** Route::group(['middleware' => 'guest', 'prefix' => 'login'], function () { Route::get('/', array("as" => "applicant_login", 'uses' => 'Portal\HomeController@applicantLogin')); Route::post('applicant-auth', array("as" => "applicant_auth", 'uses' => 'Auth\AuthController@userAuth')); }); Route::group(['middleware' => 'applicant', 'prefix' => 'applicant-user'], function () { Route::get('dashboard', array("as" => "applicant_dashboard", 'uses' => 'Applicant\ApplicantController@getIndex')); }); **AuthController.php** public function userAuth(Request $request) { $this->validate($request, ['email' => 'required','password' => 'required']); ``` $email = $request->input('email'); $password = $request->input('password'); if (Auth::attempt('user', array('email' => $email, 'password' => $password), true)) { return redirect()->route('applicant_dashboard'); } else{ Session::flash('error', 'Oops! Something went wrong. Please try again later!!'); return redirect()->back(); } } ```

Laravel 5.1 sarav multiauth ResetsPasswords method postEmail not work

I'm using sarav/multiauth and I'm trying to use the method postEmail.

But this would not be working for me. The problem is that this method find the user in other model and not the model I need.

I'm define the auth.php

'multi' => [
'admin' => [
'driver' => 'eloquent',
'model' => Infinito\Models\Admin::class,
'table' => 'admins'
],
'user' => [
'driver' => 'eloquent',
'model' => Infinito\Models\User::class,
'table' => 'users'
]
],
PasswordController.php

use Sarav\Multiauth\Foundation\ResetsPasswords;

public function __construct()
{
$this->user = "user";
}
But when I call the method postEmail in vendor sarav ResetsPasswords.php

/**

  • Send a reset link to the given user.
    *

  • @param \Illuminate\Http\Request $request

  • @return \Illuminate\Http\Response
    */
    public function postEmail(Request $request)
    {
    $this->validate($request, ['email' => 'required|email']);

    $app = app();

    $class = str_ireplace('App\Http\Controllers', '', get_called_class());

    view()->composer($app->config['auth.password.email'], function($view) use ($class) {
    $view->with('action', $class.'@getReset');
    });

    $response = Password::sendResetLink($request->only('email'), function (Message $message) {
    $message->subject($this->getEmailSubject());
    });

    switch ($response) {
    case Password::RESET_LINK_SENT:
    return redirect()->back()->with('status', trans($response));

    case Password::INVALID_USER:
        return redirect()->back()->withErrors(['email' => trans($response)]);
    

    }
    }
    I get response INVALID_USER. If I send an existing user in the admins table it works, but not is the model I need. If i send an existing user in the users table $response is INVALID_USER.

I could see that the problem is here but I have no idea because.

$response = Password::sendResetLink($request->only('email'), function (Message $message) {
$message->subject($this->getEmailSubject());
});
Any idea?

Ploblem Class 'Illuminate\Auth\Guard' not found

Hello,
Thank you for this great module!
I followed the installation instructions and by launching my program I got it: Class 'Illuminate\Auth\Guard' not found

/Users/xxx/Git/Alfred/vendor/sarav/laravel-multiauth/src/Guard.php
` <?php

namespace Sarav\Multiauth;
 
use Illuminate\Support\Facades\Auth;
use Illuminate\Auth\Guard as OriginalGuard;
use Illuminate\Contracts\Auth\UserProvider;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Session\SessionInterface as SessionStore;
 
class Guard extends OriginalGuard {
 
    protected $name;
    
    /**
     * Create a new authentication guard.
     *
     * @param  \Illuminate\Contracts\Auth\UserProvider  $provider
     * @param  \Symfony\Component\HttpFoundation\Session\SessionInterface  $session
     * @param  \Symfony\Component\HttpFoundation\Request  $request
     * @return void
     */
    public function __construct(UserProvider $provider, SessionStore $session, $name, Request $request = null)
    {
        $this->name = $name;
        parent::__construct($provider, $session, $request);
    }
 
    /**
     * Get a unique identifier for the auth session value.
     *
     * @return string
     */
    public function getName()
    {
        return 'login_' . $this->name . '_' . md5(get_class($this));
    }
 
    /**
     * Get the name of the cookie used to store the "recaller".

`

I am running PHP 7.2.7 and Laravel 5.8.14

can method for permissions return true to anything

Hi, Sarav.

I've decide to use multi authentication for laravel 5.1 in a project for basic reasons. But i'm facing a problem with @can blade directive. Virtually, this directive returns true to anything, which did not precede before using the basic auth native from Laravel 5.1. The user has a Role relationship which returns a collections of Permissions contains the following attributes:

  • id;
  • name;
  • label;

the label attribute is the string with the permission name in snaked case.

I can not resolve this using a new implementation for check permissions because i'm talking about a project in advanced production stage. I hope it's a problem with how i implemented the Multi Auth, maybe i miss something on tutorial... could you help me?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.