Reputation: 1172
I am using Laravel 5.8.
I want to add email_verified_at != null OR phone_number_verified_at != null
in auth.
How do I do that?
Upvotes: 1
Views: 1344
Reputation: 1156
Add attemptLogin
function in LoginController, this function is called by laravel to authenticate
protected function attemptLogin(Request $request)
{
$valid = $this->guard()->attempt(
$this->credentials($request), $request->filled('remember')
);
if($valid){
$user = $this->guard()->user();
if($user->email_verified_at == null && $user->phone_number_verified_at == null ){
$this->guard()->logout();
$request->session()->invalidate();
return false;
}
}
return true;
}
Upvotes: 1
Reputation: 474
Use this in web.php route Auth::routes(['verify' => true]);
Read this link https://laravel.com/docs/5.8/verification#verification-routing
if you are using this its check email verified or not Auth::routes(['verify' => true]);
If you want to more about go to this path in laravel project \vendor\laravel\framework\src\Illuminate\Auth
and see trait MustVerifyEmail
public function hasVerifiedEmail()
{
return ! is_null($this->email_verified_at);
}
You are trying to check both
overite one method
public function hasVerifiedEmail()
{
if (!is_null($this->phone_verified_at) && !is_null($this->email_verified_at)) {
return 1;
}
}
2.step go to VerificationController
/**
* Show the email verification notice.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function show(Request $request)
{
$user = Auth::user();
if (is_null($user->email_verified_at)) {
return view('auth.verify');
}elseif (is_null($user->phone_verified_at)) {
return redirect("phone_verify");
}else{
return redirect($this->redirectPath());
}
}
go to web.php
create route for phone verify
Route::get('phone_verify',function(){
dd("not verify");
});
Upvotes: 1