mardi 30 janvier 2018

What is the best way to check active status for user whille loging in native multi-auth Laravel?

I am using laravel multi-auth. I have a table column called status. At the time of login in, I want compare user whether it is active or in active. If active only login and if not give a message 'inactive account, please contacct to administrator'.

Here is my login controller.

    <?php
    namespace Modules\University\Http\Controllers;  

    class LoginController extends Controller
    {
        protected $redirectTo = '/university';

        public function __construct()
        {
            $this->middleware('guest:university', ['except' => ['universityLogout']]);
        }

        public function showLoginForm()
        {

            return view('university::login');
        }

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

            //attempt to log the user in
            if(Auth::guard('university')->attempt(['email' => $request->email, 'password' => $request->password], $request->remember)){

/****Here I want check whether university status is active or not and give message if not else login*****/

                return redirect()->intended(route('university.dashboard'));
            }


            Session::flash('failed', 'Login credential incorrect!');
            return redirect()
                ->back()
                ->withInput($request->only('email', 'remember'));
        }

        public function universityLogout(Request $request)
        {
            Auth::guard('university')->logout();
            return redirect(route('university.login'));
        }
    }

Thanks in advance.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire