1

i have three roles Hr,staff and admin... i use 3 middleware guards to guard each role.... but don't know why the staff(default web guard) won't allow me login... giving undefined index password error.

// controller function

   public function logged(Request $request)
    {
        $this->validate($request,[
            'email' => 'required|email',
            'password' => 'required|min:6'
        ]);

        if (Auth::guard('web')->attempt(['email'=>$request->email,
           'password' => $request->password]))
        {

             return redirect()->intended(url('/home'));
        }
        Session::flash('message','Invalid Login details');
        return redirect()->back()->withInput($request->only('email','remember'));
    }

//my view

<div class="m-t-40 card-box">
                <div class="panel-body">
                <div class="login-form">
                    <h4><center>Login</center></h4>
                    <form action="{{route('login.submit')}}" method="POST" data-parsley-validate >
                    <input type="hidden" name="_token" value="{{csrf_token()}}"/>
                        <input type="text" name="email" placeholder="Email address" value="{{old('email')}}" required>
                        <input type="password" name="password" class="pass" placeholder="Password" required>
                        <span class="check-left"><input type="checkbox" name="remember" {{ old('remember') ? 'checked' : '' }}> Remember Me</span>
                        <span class="check-right"><a href="{{url('/reset')}}">Forgot password?</a></span>
                        <div class="clearfix"></div>
                        <button class="btn btn-info btn-block" type="submit">Sign in</button>
                        <p class="center-block mg-t mg-b">Dont have and account?
                        <a href="{{url('/signup')}}"> Register here.</a>
                        </p>
                    </form>
                </div>
        </div>  
    </div

// config/auth

'guards' => [
        'web' => [
            'driver' => 'session',
            'provider' => 'users',
        ],

        'api' => [
            'driver' => 'token',
            'provider' => 'users',
        ],

        'admin'=> [
            'driver' => 'session',
            'provider' => 'admins',
        ],

        'admin-api' => [
            'driver' => 'token',
            'provider' => 'admins',
        ],

        'hr' => [
            'driver' => 'session',
            'provider' => 'hrs',
        ],

        'hr-api' =>[
            'driver' => 'token',
            'provider' => 'hrs'
        ],
    ],

// screenshot of the error

screenshot of the error...here u can see it picks the password

Rope
  • 21
  • 8
  • 1
    You're not trying to use the web middleware group as a guard, are you? Can you show your `config/auth.php`? – Brian Lee Jul 20 '18 at 12:03
  • @DigitalDrifter i've added the config/auth.php page above – Rope Jul 20 '18 at 14:21
  • your table seems to be missing the `password` field – lagbox Jul 20 '18 at 19:29
  • @lagbox that's not the case.... i'm using same table for other users..(hr,admin) and it's the same function,html i copied and paste for all three users – Rope Jul 23 '18 at 08:53
  • the error is for trying to get the `password` field from the `attributes` of the `GenericUser` (`password` is missing from the attributes) ... check what is returned from the query that is happening – lagbox Jul 23 '18 at 08:58
  • @lagbox that is not the case... i have other users using the table(hr,admin) and i did copy and paste for the three users login function and html... other users are working well – Rope Jul 23 '18 at 09:04
  • @lagbox i can't see what you are point at or let me say i don't understand – Rope Jul 23 '18 at 09:24

0 Answers0