Reputation: 57
I have Laravel web application with Laravel auth and also I have Laravel Nova for content management (CMS). Web-users and Laravel nova users are using the same Laravel default MySQL users table.
When the user makes register or login in from the web or from nova, Laravel logins this user in both the Laravel app and Laravel nova.
What are the best practices to separate web and nova users?
Upvotes: 0
Views: 382
Reputation: 36
You can flag the users as admin in your DB and then use that flag to authorize the user to log in nova in your NovaServiceProvider
/**
* Register the Nova gate.
*
* This gate determines who can access Nova in non-local environments.
*
* @return void
*/
protected function gate()
{
Gate::define('viewNova', function ($user) {
return $user->admin;
});
}
Or you can even put your admin emails in an array (hard coded) or in another table like that
return in_array($user->email, ["[email protected]"]);
return in_array($user->email, \App\Models\Admin::all()->pluck('email')->toArray());
Upvotes: 0
Reputation: 610
Separating nova users/admins in a new table is the best option to solve this.
Upvotes: 0