Reputation: 539
I am doing the conditional authentication for the login so the user will redirect to their pages respectively. My code is:
protected $redirectTo = '/';
protected function redirectTo()
{
if (auth()->user()->department == 'HR' || 'Human Resource' ) {
return '/hr';
}
elseif (auth()->user()->department == 'Accountant' || 'ACC' ) {
return '/acc';
}
else return '/';
}
However, when I run the code, the page is redirected to the wrong page. How to add OR clause to the parameter?
Upvotes: 1
Views: 69
Reputation: 6005
Try This Not Use directly ||
((auth()->user()->department == 'HR') || (auth()->user()->department == 'Human Resource'))
((auth()->user()->department == 'Accountant') || (auth()->user()->department == 'ACC'))
Upvotes: 1
Reputation: 3318
protected function redirectTo()
{
if ((auth()->user()->department == 'HR') || (auth()->user()->department == 'Human Resource')) {
return '/hr';
}
elseif ((auth()->user()->department == 'Accountant') || (auth()->user()->department == 'ACC')) {
return '/acc';
}
else return '/';
}
Upvotes: 1