Skip to content

Commit

Permalink
Merge pull request #3 from anomalylabs/2.6
Browse files Browse the repository at this point in the history
Sync
  • Loading branch information
MostafaMoradii committed Nov 6, 2023
2 parents c9d29b6 + ce39ee8 commit 9d25591
Show file tree
Hide file tree
Showing 24 changed files with 52 additions and 59 deletions.
4 changes: 2 additions & 2 deletions docs/en/04.extensions/02.authenticators.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ The extension you create must extend the `\Anomaly\UsersModule\User\Authenticato
*/
public function authenticate(array $credentials)
{
return $this->dispatch(new AuthenticateCredentials($credentials));
return dispatch_sync(new AuthenticateCredentials($credentials));
}
}

Expand All @@ -129,7 +129,7 @@ The primary task of any authenticators is to authenticate a login request. In th

public function authenticate(array $credentials)
{
return $this->dispatch(new AuthenticateCredentials($credentials));
return dispatch_sync(new AuthenticateCredentials($credentials));
}

Our `AuthenticateCredentials` command is responsible for the actual work:
Expand Down
4 changes: 2 additions & 2 deletions docs/en/04.extensions/03.security-checks.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ The extension you create must extend the `\Anomaly\UsersModule\User\Security\Sec
return true;
}

return $this->dispatch(new CheckUser($user));
return dispatch_sync(new CheckUser($user));
}

}
Expand All @@ -145,7 +145,7 @@ The primary task of any security check is to validate a user. In this example we
return true;
}

return $this->dispatch(new CheckUser($user));
return dispatch_sync(new CheckUser($user));
}

Our `CheckUser` command is responsible for the actual work:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ public function up()
* Ensure the potentially newly generated
* models are autoloaded so we can use them.
*/
$this->dispatchNow(new AutoloadEntryModels());
dispatch_sync(new AutoloadEntryModels());

/**
* Load the concrete on purpose.
*
Expand Down
2 changes: 1 addition & 1 deletion src/Http/Controller/RegisterController.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function register(Translator $translator)
*/
public function activate()
{
if (!$this->dispatch(new HandleActivateRequest())) {
if (!dispatch_sync(new HandleActivateRequest())) {

$this->messages->error('anomaly.module.users::error.activate_user');

Expand Down
6 changes: 0 additions & 6 deletions src/User/Command/SendActivationEmail.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,9 @@

use Anomaly\UsersModule\User\Contract\UserInterface;
use Anomaly\UsersModule\User\Notification\ActivateYourAccount;
use Illuminate\Contracts\Config\Repository;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Mail\Mailer;
use Illuminate\Mail\Message;

class SendActivationEmail
{
use DispatchesJobs;

/**
* The user instance.
*
Expand Down
4 changes: 0 additions & 4 deletions src/User/Command/SendUserRegisteredEmail.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

use Anomaly\UsersModule\User\Contract\UserInterface;
use Anomaly\UsersModule\User\Notification\ActivateYourAccount;
use Illuminate\Foundation\Bus\DispatchesJobs;

/**
* Class SendUserRegisteredEmail
Expand All @@ -13,9 +12,6 @@
*/
class SendUserRegisteredEmail
{

use DispatchesJobs;

/**
* The user instance.
*
Expand Down
4 changes: 4 additions & 0 deletions src/User/Notification/ActivateYourAccount.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ public function toMail(UserInterface $notifiable)
{
$data = $notifiable->toArray();

if (isset($data['roles'])) {
unset($data['roles']);
}

return (new MailMessage())
->view('anomaly.module.users::notifications.activate_your_account')
->subject(trans('anomaly.module.users::notification.activate_your_account.subject', $data))
Expand Down
4 changes: 4 additions & 0 deletions src/User/Notification/PasswordInvalidated.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ public function toMail(UserInterface $notifiable)
{
$data = $notifiable->toArray();

if (isset($data['roles'])) {
unset($data['roles']);
}

return (new MailMessage())
->error()
->view('anomaly.module.users::notifications.password_invalidated')
Expand Down
4 changes: 4 additions & 0 deletions src/User/Notification/ResetYourPassword.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ public function via(UserInterface $notifiable)
public function toMail(UserInterface $notifiable)
{
$data = $notifiable->toArray();

if (isset($data['roles'])) {
unset($data['roles']);
}

return (new MailMessage())
->error()
Expand Down
4 changes: 4 additions & 0 deletions src/User/Notification/UserHasBeenActivated.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ public function toMail(UserInterface $notifiable)
{
$data = $notifiable->toArray();

if (isset($data['roles'])) {
unset($data['roles']);
}

return (new MailMessage())
->view('anomaly.module.users::notifications.user_has_been_activated')
->subject(trans('anomaly.module.users::notification.user_has_been_activated.subject', $data))
Expand Down
6 changes: 5 additions & 1 deletion src/User/Notification/UserHasRegistered.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function __construct(UserInterface $user)
*/
public function via()
{
return ['mail', 'slack'];
return ['mail'];
}

/**
Expand All @@ -58,6 +58,10 @@ public function toMail(AnonymousNotifiable $notifiable)
{
$data = $this->user->toArray();

if (isset($data['roles'])) {
unset($data['roles']);
}

return (new MailMessage())
->view('anomaly.module.users::notifications.user_has_registered')
->subject(trans('anomaly.module.users::notification.user_has_registered.subject', $data))
Expand Down
4 changes: 4 additions & 0 deletions src/User/Notification/UserPendingActivation.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ public function toMail(AnonymousNotifiable $notifiable)
{
$data = $this->user->toArray();

if (isset($data['roles'])) {
unset($data['roles']);
}

return (new MailMessage())
->view('anomaly.module.users::notifications.user_pending_activation')
->subject(trans('anomaly.module.users::notification.user_pending_activation.subject', $data))
Expand Down
4 changes: 0 additions & 4 deletions src/User/Password/Command/SendInvalidatedEmail.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

use Anomaly\UsersModule\User\Contract\UserInterface;
use Anomaly\UsersModule\User\Notification\PasswordInvalidated;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Notifications\Notifiable;

/**
Expand All @@ -14,9 +13,6 @@
*/
class SendInvalidatedEmail
{

use DispatchesJobs;

/**
* The user instance.
*
Expand Down
4 changes: 0 additions & 4 deletions src/User/Password/Command/SendResetEmail.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

use Anomaly\UsersModule\User\Contract\UserInterface;
use Anomaly\UsersModule\User\Notification\ResetYourPassword;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Notifications\Notifiable;

/**
Expand All @@ -14,9 +13,6 @@
*/
class SendResetEmail
{

use DispatchesJobs;

/**
* The user instance.
*
Expand Down
6 changes: 1 addition & 5 deletions src/User/Register/Command/AssociateActivationRoles.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

use Anomaly\UsersModule\Role\Command\GetRole;
use Anomaly\UsersModule\User\Register\RegisterFormBuilder;
use Illuminate\Foundation\Bus\DispatchesJobs;

/**
* Class AssociateActivationRoles
Expand All @@ -13,9 +12,6 @@
*/
class AssociateActivationRoles
{

use DispatchesJobs;

/**
* The form builder.
*
Expand All @@ -42,7 +38,7 @@ public function handle()
$user = $this->builder->getFormEntry();

foreach ($this->builder->getRoles() as $role) {
if ($role = $this->dispatch(new GetRole($role))) {
if ($role = dispatch_sync(new GetRole($role))) {
$user->attachRole($role);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/User/Register/RegisterFormBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class RegisterFormBuilder extends FormBuilder
*/
public function onSaved()
{
$this->dispatch(new AssociateActivationRoles($this));
dispatch_sync(new AssociateActivationRoles($this));
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/User/Register/RegisterFormHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ public function handle(

switch ($mode) {
case 'automatic':
dispatch_now(new HandleAutomaticRegistration($builder));
dispatch_sync(new HandleAutomaticRegistration($builder));
break;

case 'manual':
dispatch_now(new HandleManualRegistration($builder));
dispatch_sync(new HandleManualRegistration($builder));
break;

case 'email':
dispatch_now(new HandleEmailRegistration($builder));
dispatch_sync(new HandleEmailRegistration($builder));
break;
}

Expand Down
11 changes: 4 additions & 7 deletions src/User/UserActivator.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,9 @@
use Anomaly\UsersModule\User\Command\SendActivationEmail;
use Anomaly\UsersModule\User\Command\StartUserActivation;
use Anomaly\UsersModule\User\Contract\UserInterface;
use Illuminate\Foundation\Bus\DispatchesJobs;

class UserActivator
{
use DispatchesJobs;

/**
* Start a user activation process.
*
Expand All @@ -19,7 +16,7 @@ class UserActivator
*/
public function start(UserInterface $user)
{
return $this->dispatch(new StartUserActivation($user));
return dispatch_sync(new StartUserActivation($user));
}

/**
Expand All @@ -31,7 +28,7 @@ public function start(UserInterface $user)
*/
public function activate(UserInterface $user, $code)
{
return $this->dispatch(new ActivateUserByCode($user, $code));
return dispatch_sync(new ActivateUserByCode($user, $code));
}

/**
Expand All @@ -42,7 +39,7 @@ public function activate(UserInterface $user, $code)
*/
public function force(UserInterface $user)
{
return $this->dispatch(new ActivateUserByForce($user));
return dispatch_sync(new ActivateUserByForce($user));
}

/**
Expand All @@ -54,6 +51,6 @@ public function force(UserInterface $user)
*/
public function send(UserInterface $user, $redirect = '/')
{
return $this->dispatch(new SendActivationEmail($user, $redirect));
return dispatch_sync(new SendActivationEmail($user, $redirect));
}
}
2 changes: 1 addition & 1 deletion src/User/UserModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public function getRoles()
public function hasRole($role)
{
if (!is_object($role)) {
$role = $this->dispatch(new GetRole($role));
$role = dispatch_sync(new GetRole($role));
}

if (!$role) {
Expand Down
2 changes: 1 addition & 1 deletion src/User/UserObserver.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class UserObserver extends EntryObserver
*/
public function creating(EntryInterface $entry)
{
$this->dispatchNow(new SetStrId($entry));
dispatch_sync(new SetStrId($entry));

parent::creating($entry);
}
Expand Down
16 changes: 6 additions & 10 deletions src/User/UserPassword.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use Anomaly\UsersModule\User\Password\Command\SendInvalidatedEmail;
use Anomaly\UsersModule\User\Password\Command\SendResetEmail;
use Anomaly\UsersModule\User\Password\Command\StartPasswordReset;
use Illuminate\Foundation\Bus\DispatchesJobs;

/**
* Class UserPassword
Expand All @@ -18,9 +17,6 @@
*/
class UserPassword
{

use DispatchesJobs;

/**
* Check if the password passes validation.
*
Expand All @@ -40,7 +36,7 @@ public function passes($password)
*/
public function validate($password)
{
return $this->dispatch(new ValidatePasswordStrength($password));
return dispatch_sync(new ValidatePasswordStrength($password));
}

/**
Expand All @@ -51,7 +47,7 @@ public function validate($password)
*/
public function forgot(UserInterface $user)
{
return $this->dispatch(new StartPasswordReset($user));
return dispatch_sync(new StartPasswordReset($user));
}

/**
Expand All @@ -64,7 +60,7 @@ public function forgot(UserInterface $user)
*/
public function reset(UserInterface $user, $code, $password)
{
return $this->dispatch(new ResetPassword($user, $code, $password));
return dispatch_sync(new ResetPassword($user, $code, $password));
}

/**
Expand All @@ -76,7 +72,7 @@ public function reset(UserInterface $user, $code, $password)
*/
public function send(UserInterface $user, $reset = '/')
{
return $this->dispatch(new SendResetEmail($user, $reset));
return dispatch_sync(new SendResetEmail($user, $reset));
}

/**
Expand All @@ -89,9 +85,9 @@ public function send(UserInterface $user, $reset = '/')
public function invalidate(UserInterface $user, $reset = '/')
{
$this->forgot($user);
$this->dispatch(new InvalidatePassword($user));
dispatch_sync(new InvalidatePassword($user));

return $this->dispatch(new SendInvalidatedEmail($user, $reset));
return dispatch_sync(new SendInvalidatedEmail($user, $reset));
}

}
2 changes: 1 addition & 1 deletion src/UsersModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class UsersModule extends Module
public function onRegistered()
{
if ($this->isInstalled()) {
$this->dispatch(new SetGuestRole());
dispatch_sync(new SetGuestRole());
}
}

Expand Down
Loading

0 comments on commit 9d25591

Please sign in to comment.