Skip to content

Working version#1

Merged
ikovalyov merged 7 commits into
masterfrom
Usermodule-role-system
Jan 23, 2017
Merged

Working version#1
ikovalyov merged 7 commits into
masterfrom
Usermodule-role-system

Conversation

@Xapp73
Copy link
Copy Markdown

@Xapp73 Xapp73 commented Jan 19, 2017

No description provided.

Comment thread src/Form/UserForm.php Outdated
}


$roles = $this->entityManager->getRepository(Role::class)->findAll();
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

shouldn't be here at all

Comment thread src/Form/UserForm.php Outdated

'options' => [
'label' => 'Role',
'value_options' => $rolesselector,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

get this info in controller

Comment thread src/Form/UserForm.php
'name' => 'password',
'required' => true,
'filters' => [
['name' => 'StringTrim'],
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

StringTrim filter was removed?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

No, it seems that You have been mistaken by old filters and new filters location

Comment thread src/Service/UserManager.php Outdated

// Get role object based on role Id from form
/** @var Role $role */
$role = $this->entityManager->find(Role::class, ['roleId' => $data['role']]);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

can't you just pass role id here? I guess doctrine is smart enough.

/** @var Role $role */
$role = $this->entityManager->find(Role::class, ['roleId' => $data['role']]);
// Set role to user
$user->addRole($role);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

same

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Also don't forget to remove previous role

/** @var Role $role */
$role = $this->entityManager->find(Role::class, ['roleId' => 2]);
// Set role to user
$user->addRole($role);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

same

Comment thread src/Service/UserManager.php Outdated

// Get role object based on role Id from form
/** @var Role $role */
$role = $this->entityManager->find(Role::class, ['roleId' => 2]);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

2 should be a constant

Comment thread view/user/user/add.phtml
'placeholder'=>'John Doe'
]);

$form->get('role')->setAttributes([
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

write it in template instead of using jquery

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

did it as it is at native code, so no idea what do You want here

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

shitty code :(

Comment thread view/user/user/edit.phtml
'placeholder'=>'John Doe'
]);

$form->get('role')->setAttributes([
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

same

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

did it as it is at native code, so no idea what do You want here

@Xapp73 Xapp73 changed the title Broken version Working version Jan 20, 2017
Comment thread src/Controller/UserController.php Outdated
public function getRolesSelector()
{
$roles = $this->entityManager->getRepository(Role::class)->findAll();
$hydrator = new \Zend\Hydrator\ClassMethods();
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

use ClassMethods

Comment thread src/Controller/UserController.php Outdated
{
// checking for existing role if editing mode
$rolecurrent['role_id'] = self::GUEST_ROLE_ID;
$hydrator = new \Zend\Hydrator\ClassMethods();
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

same

Comment thread src/Service/AuthManager.php Outdated
if ($allow=='*')
return true; // Anyone is allowed to see the page.
else if ($allow=='@' && $this->authService->hasIdentity()) {
else if (($allow=='@' || is_array($allow)) && $this->authService->hasIdentity()) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I don't really like the @ behaviour. It cab be easily resolved with "user" role which cover every logged in user.

@ikovalyov ikovalyov merged commit 6f597ff into master Jan 23, 2017
@ikovalyov ikovalyov deleted the Usermodule-role-system branch January 23, 2017 17:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants