Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding fix for Role feature state check #2851

Merged
merged 9 commits into from
May 2, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions resources/lang/en/role.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php

return array(
'rolesNotEnabled' => 'The roles feature is not enabled for your deployment.'
);
1 change: 1 addition & 0 deletions src/App/Init.php
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,7 @@
];
$di->params[Ushahidi\App\Validator\Role\Update::class] = [
'permission_repo' => $di->lazyGet('repository.permission'),
'feature' => $di->lazyGet('features.roles'),
];

// Validator Setters
Expand Down
15 changes: 13 additions & 2 deletions src/App/Validator/Role/Update.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@
use Ushahidi\Core\Entity\PermissionRepository;

class Update extends Validator
{
{
protected $permission_repo;
protected $feature;
protected $default_error_source = 'role';

public function __construct(PermissionRepository $permission_repo)
public function __construct(PermissionRepository $permission_repo, array $feature)
{
$this->permission_repo = $permission_repo;
$this->feature = $feature;
}

protected function getRules()
Expand All @@ -36,6 +38,15 @@ protected function getRules()
];
}

public function checkRolesEnabled(\Kohana\Validation\Validation $validation, $permissions)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple of things:

  1. Don't you need to add this into getRules above?
  2. Should updates fail entirely? or should we be able to rename roles in the free tier?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just realised this is going back to the lumen branch. You need to change the interface to rely on Ushahidi\Core\Tool\ValidationEngine instead. It should work as written otherwise

Copy link
Contributor Author

@willdoran willdoran Apr 30, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should updates fail entirely? or should we be able to rename roles in the free tier?

nope no changes to roles at all allowed

Don't you need to add this into getRules above?

yep

Copy link
Contributor Author

@willdoran willdoran Apr 30, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to change the interface to rely on Ushahidi\Core\Tool\ValidationEngine instead.

Can you link an example from the other validators, not sure I follow.

{
if ($this->feature['enabled']) {
$validation->error('role', 'rolesNotEnabled');
return;
}
return;
}

public function checkPermissions(\Kohana\Validation\Validation $validation, $permissions)
{
if (!$permissions) {
Expand Down