Inject the account information as a Javascript variable

Check the registration and authentication status and inject this variable once the email is validated or the account authenticated
Bump the package number
Fix #8
This commit is contained in:
Timothée Jaussoin 2021-05-05 15:58:25 +02:00
parent 4fbdf5842b
commit 48bc542097
7 changed files with 39 additions and 4 deletions

View file

@ -85,6 +85,9 @@ class AuthenticateController extends Controller
]);
}
/**
* Display the form
*/
public function authenticateEmail(Request $request)
{
$request->validate([
@ -109,6 +112,20 @@ class AuthenticateController extends Controller
Mail::to($account)->send(new PasswordAuthentication($account));
return redirect()->route('account.check.email', $account->identifier);
}
/**
* A page that check if the email was validated and reload if not
*/
public function checkEmail(Request $request, string $sip)
{
if (auth()->user()) {
return redirect()->route('account.panel');
}
$account = Account::sip($sip)->firstOrFail();
return view('account.authenticate.email', [
'account' => $account
]);

View file

@ -98,9 +98,7 @@ class RegisterController extends Controller
Mail::to($account)->send(new RegisterConfirmation($account));
return view('account.authenticate.email', [
'account' => $account
]);
return redirect()->route('account.check.email', $account->identifier);
}
public function storePhone(Request $request)

View file

@ -6,8 +6,13 @@
@else
@if ($account->activated)
<p>A unique authentication link was sent by email to <b>{{ $account->email }}</b>.</p>
@include('parts.account_variables', ['account' => $account])
@else
<p>To finish your registration process and set a password please follow the link sent on your email address <b>{{ $account->email }}</b>.</p>
<script type="text/javascript">
setTimeout(function () { location.reload(1); }, 5000);
</script>
@endif
@endif
@endsection

View file

@ -91,4 +91,6 @@
@endif
</div>
@include('parts.account_variables', ['account' => $account])
@endsection

View file

@ -0,0 +1,12 @@
@if ($account)
<script type="text/javascript">
var account_infos = {
sip: '{{ $account->identifier }}',
username: '{{ $account->username }}',
@if (!empty(config('app.proxy_registrar_address')))
registrar_address: '{{ config('app.proxy_registrar_address') }}',
@endif
domain: '{{ $account->domain }}'
}
</script>
@endif

View file

@ -24,6 +24,7 @@ Route::post('authenticate', 'Account\AuthenticateController@authenticate')->name
Route::get('login/email', 'Account\AuthenticateController@loginEmail')->name('account.login_email');
Route::post('authenticate/email', 'Account\AuthenticateController@authenticateEmail')->name('account.authenticate.email');
Route::get('authenticate/email/check/{sip}', 'Account\AuthenticateController@checkEmail')->name('account.check.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');

View file

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