mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-12-27 04:10:52 -05:00
53 lines
1.2 KiB
PHP
53 lines
1.2 KiB
PHP
<?php namespace app\Listeners;
|
|
|
|
use Utils;
|
|
use Auth;
|
|
use App\Events\UserSignedUp;
|
|
use App\Models\Activity;
|
|
use App\Ninja\Repositories\AccountRepository;
|
|
use App\Ninja\Mailers\UserMailer;
|
|
|
|
class HandleUserSignedUp
|
|
{
|
|
protected $accountRepo;
|
|
protected $userMailer;
|
|
|
|
/**
|
|
* Create the event handler.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function __construct(AccountRepository $accountRepo, UserMailer $userMailer)
|
|
{
|
|
$this->accountRepo = $accountRepo;
|
|
$this->userMailer = $userMailer;
|
|
}
|
|
|
|
/**
|
|
* Handle the event.
|
|
*
|
|
* @param UserSignedUp $event
|
|
* @return void
|
|
*/
|
|
public function handle(UserSignedUp $event)
|
|
{
|
|
$user = Auth::user();
|
|
|
|
if (Utils::isNinjaProd()) {
|
|
$this->userMailer->sendConfirmation($user);
|
|
} elseif (Utils::isNinjaDev()) {
|
|
// do nothing
|
|
} else {
|
|
$this->accountRepo->registerNinjaUser($user);
|
|
}
|
|
|
|
$activities = Activity::scope()->get();
|
|
foreach ($activities as $activity) {
|
|
$activity->message = str_replace('Guest', $user->getFullName(), $activity->message);
|
|
$activity->save();
|
|
}
|
|
|
|
session([SESSION_COUNTER => -1]);
|
|
}
|
|
}
|