Fix some authentication and redirection errors

Bump version to 63
This commit is contained in:
Timothée Jaussoin 2021-04-29 11:11:09 +02:00
parent 34462596d1
commit a60fe69c6a
3 changed files with 22 additions and 5 deletions

View file

@ -85,6 +85,11 @@ class AuthenticateController extends Controller
]);
}
public function authenticateEmailToLogin(Request $request)
{
return redirect()->route('account.login_email');
}
public function authenticateEmail(Request $request)
{
$request->validate([
@ -118,7 +123,12 @@ class AuthenticateController extends Controller
$request->merge(['code' => $code]);
$request->validate(['code' => 'required|size:'.self::$emailCodeSize]);
$account = Account::where('confirmation_key', $code)->firstOrFail();
$account = Account::where('confirmation_key', $code)->first();
if (!$account) {
return redirect()->route('account.login_email');
}
$account->confirmation_key = null;
// If there is already a password set, we directly activate the account
@ -145,6 +155,11 @@ class AuthenticateController extends Controller
return view('account.login.phone');
}
public function authenticatePhoneToLogin(Request $request)
{
return redirect()->route('account.login_phone');
}
public function authenticatePhone(Request $request)
{
$request->validate([
@ -165,8 +180,8 @@ class AuthenticateController extends Controller
}
if (!$account) {
return view('account.login_phone')->withErrors([
'phone' => 'Phone number not found'
return redirect()->back()->withErrors([
'phone' => 'Invalid phone number'
]);
}
@ -197,7 +212,7 @@ class AuthenticateController extends Controller
->firstOrFail();
if ($account->confirmation_key != $request->get('code')) {
return view('account.login_phone')->withErrors([
return redirect()->back()->withErrors([
'code' => 'Wrong code'
]);
}

View file

@ -25,10 +25,12 @@ Route::get('login', 'Account\AuthenticateController@login')->name('account.login
Route::post('authenticate', 'Account\AuthenticateController@authenticate')->name('account.authenticate');
Route::get('login/email', 'Account\AuthenticateController@loginEmail')->name('account.login_email');
Route::get('authenticate/email', 'Account\AuthenticateController@authenticateEmailToLogin');
Route::post('authenticate/email', 'Account\AuthenticateController@authenticateEmail')->name('account.authenticate.email');
Route::get('authenticate/email/{code}', 'Account\AuthenticateController@validateEmail')->name('account.authenticate.email_confirm');
Route::get('login/phone', 'Account\AuthenticateController@loginPhone')->name('account.login_phone');
Route::get('authenticate/phone', 'Account\AuthenticateController@authenticatePhoneToLogin');
Route::post('authenticate/phone', 'Account\AuthenticateController@authenticatePhone')->name('account.authenticate.phone');
Route::post('authenticate/phone/confirm', 'Account\AuthenticateController@validatePhone')->name('account.authenticate.phone_confirm');

View file

@ -8,7 +8,7 @@
#%define _datadir %{_datarootdir}
#%define _docdir %{_datadir}/doc
%define build_number 62
%define build_number 63
%define var_dir /var/opt/belledonne-communications
%define opt_dir /opt/belledonne-communications/share/flexisip-account-manager
%define env_file "$RPM_BUILD_ROOT/etc/flexisip-account-manager/flexiapi.env"