1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 13:12:50 +01:00

Working on user notifications when an email changes

This commit is contained in:
David Bomba 2020-07-22 12:25:58 +10:00
parent 532e3fd484
commit 9d276ffa70
5 changed files with 112 additions and 7 deletions

View File

@ -27,8 +27,6 @@ class CompanyUserController extends BaseController
public function __construct()
{
parent::__construct();
//$this->middleware('guest');
}
/**
@ -38,7 +36,6 @@ class CompanyUserController extends BaseController
*/
public function index()
{
// return view('signup.index');
}
/**
@ -48,11 +45,10 @@ class CompanyUserController extends BaseController
*/
public function create()
{
//
}
public function store(CreateAccountRequest $request)
public function store()
{
}
@ -125,8 +121,8 @@ class CompanyUserController extends BaseController
*/
public function update(UpdateCompanyUserRequest $request, User $user)
{
$company = auth()->user()->company();
$company = auth()->user()->company();
$company_user = CompanyUser::whereUserId($user->id)->whereCompanyId($company->id)->first();
@ -145,6 +141,7 @@ class CompanyUserController extends BaseController
$company_user->save();
return $this->itemResponse($company_user->fresh());
}
/**

View File

@ -13,6 +13,8 @@ namespace App\Http\Controllers;
use App\DataMapper\CompanySettings;
use App\DataMapper\DefaultSettings;
use App\Events\User\UserEmailAddressChangedNewEmail;
use App\Events\User\UserEmailAddressChangedOldEmail;
use App\Factory\UserFactory;
use App\Filters\UserFilters;
use App\Http\Controllers\Traits\VerifiesUserEmail;
@ -30,6 +32,7 @@ use App\Models\CompanyUser;
use App\Models\User;
use App\Repositories\UserRepository;
use App\Transformers\UserTransformer;
use App\Utils\Ninja;
use App\Utils\Traits\MakesHash;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;
@ -367,8 +370,12 @@ class UserController extends BaseController
*/
public function update(UpdateUserRequest $request, User $user)
{
event(new UserEmailAddressChangedOldEmail($user->email, auth()->user()->company(), Ninja::eventVars()));
$user = $this->user_repo->save($request->all(), $user);
event(new UserEmailAddressChangedNewEmail($user->email, auth()->user()->company(), Ninja::eventVars()));
return $this->itemResponse($user);
}

View File

@ -0,0 +1,51 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com)
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace App\Jobs\User;
use App\Jobs\Mail\BaseMailerJob;
use App\Models\Company;
use Illuminate\Http\Request;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
class UserEmailChangedNew extends BaseMailerJob implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
protected $email;
protected $company;
/**
* Create a new job instance.
*
* @return void
*/
public function __construct(string $email, Company $company)
{
$this->email = $email;
$this->company = $company;
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
}
}

View File

@ -0,0 +1,51 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com)
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace App\Jobs\User;
use App\Jobs\Mail\BaseMailerJob;
use App\Models\Company;
use Illuminate\Http\Request;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
class UserEmailChangedOld extends BaseMailerJob implements ShouldQueue
{
use Dispatchable;
protected $email;
protected $company;
/**
* Create a new job instance.
*
* @return void
*/
public function __construct(string $email, Company $company)
{
$this->email = $email;
$this->company = $company;
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
}
}

View File

@ -241,7 +241,6 @@ class EventServiceProvider extends ServiceProvider
QuoteWasViewed::class => [
QuoteViewedActivity::class,
],
];
/**