diff --git a/flexiapi/app/Account.php b/flexiapi/app/Account.php index 8e69808..0d17b21 100644 --- a/flexiapi/app/Account.php +++ b/flexiapi/app/Account.php @@ -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)); } diff --git a/flexiapi/app/Http/Controllers/Account/AuthenticateController.php b/flexiapi/app/Http/Controllers/Account/AuthenticateController.php index 85032dd..dc398a2 100644 --- a/flexiapi/app/Http/Controllers/Account/AuthenticateController.php +++ b/flexiapi/app/Http/Controllers/Account/AuthenticateController.php @@ -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(); diff --git a/flexiapi/app/Http/Controllers/Account/EmailController.php b/flexiapi/app/Http/Controllers/Account/EmailController.php index ab92886..ce98dd9 100644 --- a/flexiapi/app/Http/Controllers/Account/EmailController.php +++ b/flexiapi/app/Http/Controllers/Account/EmailController.php @@ -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')); diff --git a/flexiapi/resources/views/mails/changing_email.blade.php b/flexiapi/resources/views/mails/changing_email.blade.php index 021a6de..2091a90 100644 --- a/flexiapi/resources/views/mails/changing_email.blade.php +++ b/flexiapi/resources/views/mails/changing_email.blade.php @@ -5,7 +5,7 @@
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 to {{ $account->emailChanged->new_email }} on {{ config('app.name') }}.
To confirm this change please click on the following link: diff --git a/flexiapi/resources/views/mails/changing_email_text.blade.php b/flexiapi/resources/views/mails/changing_email_text.blade.php index 5b9c046..1727137 100644 --- a/flexiapi/resources/views/mails/changing_email_text.blade.php +++ b/flexiapi/resources/views/mails/changing_email_text.blade.php @@ -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) }}. diff --git a/flexisip-account-manager.spec b/flexisip-account-manager.spec index 1570bc1..6b5f50c 100644 --- a/flexisip-account-manager.spec +++ b/flexisip-account-manager.spec @@ -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