vendredi 31 mai 2019

How will I set if account_status = 1 then I can able to login otherwise not able to login?

How will I set if account_status = 1 then I can able to login otherwise not able to login? email, phone and password must be there. This is the following code

public function login(Request $request){ 

        if(Auth::attempt(['email' => request('email'), 'password' => request('password'),
        'account_status'=> request('account_status')])){ 
            $user = Auth::user(); 
            $success['token'] =  $user->createToken('MyApp')-> accessToken; 
            return response()->json(['success' => $success], $this-> successStatus); 
        } 
        else if(Auth::attempt(['phone' => request('phone'), 'password' => request('password'),
        'account_status'=> request('account_status')])){
            $user = Auth::user(); 
            $success['token'] =  $user->createToken('MyApp')-> accessToken; 
            return response()->json(['success' => $success], $this-> successStatus);
        }
        else{ 
            return response()->json(['error'=>'Unauthorised'], 401); 
        } 
    }

Please help me out to solve this problem i'll be grateful to you



from Newest questions tagged laravel-5 - Stack Overflow http://bit.ly/2Iav8ZI
via IFTTT

Aucun commentaire:

Enregistrer un commentaire