mirror of
https://github.com/flarum/core.git
synced 2025-10-12 23:44:27 +02:00
- Split user edit permision into edit attributes, edit credentials, and edit groups - Only Admins can edit Admin Credentials - Only Admins can Promote/Demote to/from Admin
43 lines
878 B
PHP
43 lines
878 B
PHP
<?php
|
|
|
|
/*
|
|
* This file is part of Flarum.
|
|
*
|
|
* For detailed copyright and license information, please view the
|
|
* LICENSE file that was distributed with this source code.
|
|
*/
|
|
|
|
namespace Flarum\User\Access;
|
|
|
|
use Flarum\User\User;
|
|
|
|
class UserPolicy extends AbstractPolicy
|
|
{
|
|
/**
|
|
* @param User $actor
|
|
* @param string $ability
|
|
* @return bool|null
|
|
*/
|
|
public function can(User $actor, $ability)
|
|
{
|
|
if ($actor->hasPermission('user.'.$ability)) {
|
|
return $this->allow();
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @param User $actor
|
|
* @param User $user
|
|
*/
|
|
public function editCredentials(User $actor, User $user)
|
|
{
|
|
if ($user->isAdmin() && ! $actor->isAdmin()) {
|
|
return $this->deny();
|
|
}
|
|
|
|
if ($actor->hasPermission('user.editCredentials')) {
|
|
return $this->allow();
|
|
}
|
|
}
|
|
}
|