Added a has_organisation authorizer check
This commit is contained in:
@@ -59,6 +59,20 @@ class ServicesProvider
|
||||
* @return \UserFrosting\Sprinkle\Core\Util\ClassMapper
|
||||
*/
|
||||
$container->extend('authorizer', function ($authorizer, $c) {
|
||||
/*
|
||||
* Check if all $user has an $organisation.
|
||||
*
|
||||
* @param int $user_id the id of the requesting user (normally currentUser->id).
|
||||
* @return bool true if $user is a verified member of any organisation.
|
||||
*/
|
||||
$authorizer->addCallback('has_organisation', function ($user_id) {
|
||||
$query = Capsule::table('organisation_members')
|
||||
->where('user_id', $user_id)
|
||||
->where('flag_approved', true);
|
||||
|
||||
return $query->count() > 0;
|
||||
});
|
||||
|
||||
/*
|
||||
* Check if all $user is a member of $organisation.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user