mirror of
https://github.com/openclassify/openclassify.git
synced 2026-02-09 14:56:13 -06:00
Merge pull request #753 from openclassify/muammertop
oc.com role assignment at the user registration stage
This commit is contained in:
commit
8562f97fdd
@ -1,50 +0,0 @@
|
|||||||
<?php namespace Visiosoft\ProfileModule\Profile\Register2\Command;
|
|
||||||
|
|
||||||
use Anomaly\UsersModule\Role\Command\GetRole;
|
|
||||||
use Visiosoft\ProfileModule\Profile\Register2\Register2FormBuilder;
|
|
||||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class AssociateActivationRoles
|
|
||||||
*
|
|
||||||
* @link http://openclassify.com/
|
|
||||||
* @author OpenClassify, Inc. <support@openclassify.com>
|
|
||||||
* @author Visiosoft Inc <support@openclassify.com>
|
|
||||||
*/
|
|
||||||
class AssociateActivationRoles
|
|
||||||
{
|
|
||||||
|
|
||||||
use DispatchesJobs;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The form builder.
|
|
||||||
*
|
|
||||||
* @var RegisterFormBuilder
|
|
||||||
*/
|
|
||||||
protected $builder;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new AssociateActivationRoles instance.
|
|
||||||
*
|
|
||||||
* @param RegisterFormBuilder $builder
|
|
||||||
*/
|
|
||||||
public function __construct(Register2FormBuilder $builder)
|
|
||||||
{
|
|
||||||
$this->builder = $builder;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handle the command.
|
|
||||||
*/
|
|
||||||
public function handle()
|
|
||||||
{
|
|
||||||
/* @var UserInterface $user */
|
|
||||||
$user = $this->builder->getFormEntry();
|
|
||||||
|
|
||||||
foreach ($this->builder->getRoles() as $role) {
|
|
||||||
if ($role = $this->dispatch(new GetRole($role))) {
|
|
||||||
$user->attachRole($role);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,7 +1,6 @@
|
|||||||
<?php namespace Visiosoft\ProfileModule\Profile\Register2;
|
<?php namespace Visiosoft\ProfileModule\Profile\Register2;
|
||||||
|
|
||||||
use Anomaly\Streams\Platform\Ui\Form\FormBuilder;
|
use Anomaly\Streams\Platform\Ui\Form\FormBuilder;
|
||||||
use Visiosoft\ProfileModule\Profile\Register2\Command\AssociateActivationRoles;
|
|
||||||
use Visiosoft\ProfileModule\Profile\Register2\Command\SetOptions;
|
use Visiosoft\ProfileModule\Profile\Register2\Command\SetOptions;
|
||||||
use Anomaly\UsersModule\User\UserModel;
|
use Anomaly\UsersModule\User\UserModel;
|
||||||
use Visiosoft\ProfileModule\Profile\Validation\ValidateRegister;
|
use Visiosoft\ProfileModule\Profile\Validation\ValidateRegister;
|
||||||
@ -94,14 +93,6 @@ class Register2FormBuilder extends FormBuilder
|
|||||||
'activated_message' => 'anomaly.module.users::message.account_activated',
|
'activated_message' => 'anomaly.module.users::message.account_activated',
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
|
||||||
* Fired after the form is saved.
|
|
||||||
*/
|
|
||||||
public function onSaved()
|
|
||||||
{
|
|
||||||
$this->dispatch(new AssociateActivationRoles($this));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the roles.
|
* Get the roles.
|
||||||
*
|
*
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
<?php namespace Visiosoft\ProfileModule\Profile\Register2;
|
<?php namespace Visiosoft\ProfileModule\Profile\Register2;
|
||||||
|
|
||||||
|
use Anomaly\UsersModule\Role\Command\GetRole;
|
||||||
use Anomaly\UsersModule\User\Contract\UserInterface;
|
use Anomaly\UsersModule\User\Contract\UserInterface;
|
||||||
use Anomaly\UsersModule\User\Contract\UserRepositoryInterface;
|
use Anomaly\UsersModule\User\Contract\UserRepositoryInterface;
|
||||||
use Anomaly\UsersModule\User\Event\UserHasRegistered;
|
use Anomaly\UsersModule\User\Event\UserHasRegistered;
|
||||||
@ -84,6 +85,14 @@ class Register2FormHandler
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$user = $builder->getFormEntry();
|
||||||
|
|
||||||
|
foreach ($builder->getRoles() as $role) {
|
||||||
|
if ($role = $this->dispatch(new GetRole($role))) {
|
||||||
|
$user->attachRole($role);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$events->dispatch(new UserHasRegistered($user));
|
$events->dispatch(new UserHasRegistered($user));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user