lundi 27 juillet 2020

Login users created by admin in laravel

In my application, i have admin that can create different role and user to access the admin panel, for that i am inserting a new user in the user table whose structure is :

Users:

id | name | email | password | role_id

role id 1 and 2 is fixed for admin and normal customer respectively but after creating sub user that user cannot login because in the admin controller i have checked 1 role id for Admin but sub users have different roles also (for eg. Manager can have role id-4 and so on)

This is the Admin login controller snippet :

 $request->merge(["role_id" => 1]);
    if (Auth::guard('admin')->attempt([
        'email' => $request->email,
        'password' => $request->password,'role_id' => $request->role_id
    ], $request->input('remember_me'))) {
        return redirect()->intended(route('admin.dashboard'));
    }


from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3jGAQEB
via IFTTT

Aucun commentaire:

Enregistrer un commentaire