- Fix an issue when the user set for the first time his email adress to his account (the old email was required)

- Fix an issue when a user want to do an email authentication on an account that is using the same email adress as another account
- Bump the package number
This commit is contained in:
Timothée Jaussoin 2021-05-04 11:27:21 +02:00
parent d0cce36eeb
commit 8acd08607c
6 changed files with 17 additions and 10 deletions

View file

@ -163,6 +163,9 @@ class Account extends Authenticatable
$this->refresh();
// Set it temporary to try to send the validation email
$this->email = $newEmail;
Mail::to($this)->send(new ChangingEmail($this));
}

View file

@ -102,6 +102,7 @@ class AuthenticateController extends Controller
* Because several accounts can have the same email
*/
$account = Account::where('email', $request->get('email'))
->where('username', $request->get('username'))
->first();
$account->confirmation_key = Str::random(self::$emailCodeSize);
$account->save();

View file

@ -21,13 +21,10 @@ namespace App\Http\Controllers\Account;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Mail;
use Illuminate\Support\Str;
use Illuminate\Validation\Rule;
use App\Http\Controllers\Controller;
use App\Mail\ChangingEmail;
use App\Mail\ChangedEmail;
use App\EmailChanged;
class EmailController extends Controller
{
@ -40,10 +37,16 @@ class EmailController extends Controller
public function requestUpdate(Request $request)
{
$request->validate([
'email_current' => ['required', Rule::in([$request->user()->email])],
'email' => 'required|different:email_current|confirmed|email',
]);
if ($request->user()->email) {
$request->validate([
'email_current' => ['required', Rule::in([$request->user()->email])],
'email' => 'required|different:email_current|confirmed|email',
]);
} else {
$request->validate([
'email' => 'required|confirmed|email',
]);
}
$request->user()->requestEmailUpdate($request->get('email'));

View file

@ -5,7 +5,7 @@
<body>
<p>Hello,</p>
<p>
You requested to change your email address from {{ $account->email }} to {{ $account->emailChanged->new_email }} on {{ config('app.name') }}.
You requested to change your email address to {{ $account->emailChanged->new_email }} on {{ config('app.name') }}.
</p>
<p>
To confirm this change please click on the following link:

View file

@ -1,6 +1,6 @@
Hello,
You requested to change your email address from {{ $account->email }} to {{ $account->emailChanged->new_email }} on {{ config('app.name') }}.
You requested to change your email address from {{ $account->emailChanged->new_email }} on {{ config('app.name') }}.
To confirm this change please click on the following link: {{ route('account.email.request_update', $account->emailChanged->hash) }}.

View file

@ -8,7 +8,7 @@
#%define _datadir %{_datarootdir}
#%define _docdir %{_datadir}/doc
%define build_number 64
%define build_number 65
%define var_dir /var/opt/belledonne-communications
%define opt_dir /opt/belledonne-communications/share/flexisip-account-manager