0
votes

I am using Confide (v3.2) and Entrust(v1.2) with Frozennode Administrator. In the config file there is an option which I need to set that will return true/false depending on if the user is authenticated.

/**
 * The permission option is the highest-level authentication check that lets you define a closure that should return true if the current user
 * is allowed to view the admin section. Any "falsey" response will send the user back to the 'login_path' defined below.
 *
 * @type closure
 */
'permission'=> function()
{
    return Auth::check();
},

It is using the default Laravel Auth:check(); I used confide Confide to authenticate users, but it just verifies any User is authenticated and I need to make sure they have the Admin role to use the Administrator. I am using Entrust for roles and want to get the equivalent. I only see in the documentation for Entrust to use

$user->hasRole("Admin");

But I know this won't work because $user is not defined. How do I do this?

1
I am not familiar with the packages you use, but if you can use Auth::check(), perhaps you could also use Auth::user()->hasRole('Admin') to get the current user's status? Probably not, but I thought I'd throw it out there. :)Joel Hinz
I think you are correct. Seems so obvious, but I guess I wasn't thinking straight! I am having other issues so I cannot verify and will come back to accept you answer if you make one.Phil
Glad it helped. And thanks, I'll be happy to make a reply out of it. Hope you get the rest working!Joel Hinz

1 Answers

0
votes

I am not familiar with the packages you use, but if you can use Auth::check(), you can probably also use Auth::user()->hasRole('Admin') to get the current user's status and go from there.