Improved registration logic, localized registration page.
This commit is contained in:
parent
00e2a43015
commit
561ab7ea97
@ -35,8 +35,9 @@ protected function validator(array $data): \Illuminate\Validation\Validator
|
||||
/**
|
||||
* Create a new user instance after a valid registration.
|
||||
*
|
||||
* @param array $data
|
||||
* @param array $data
|
||||
* @return Account
|
||||
* @throws \Throwable
|
||||
*/
|
||||
protected function create(array $data): Account
|
||||
{
|
||||
@ -50,6 +51,35 @@ protected function create(array $data): Account
|
||||
return $account;
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes the registration logic on a validator input
|
||||
*
|
||||
* @param \Illuminate\Validation\Validator $validator
|
||||
* @return RedirectResponse
|
||||
* @throws ValidationException
|
||||
* @throws \Throwable
|
||||
*/
|
||||
protected function runRegistrationLogic(\Illuminate\Validation\Validator $validator): RedirectResponse
|
||||
{
|
||||
// Validate the input
|
||||
if ($validator->fails()) {
|
||||
return redirect('user/register')
|
||||
->withErrors($validator)
|
||||
->withInput($validator->getData());
|
||||
}
|
||||
|
||||
// Retrieve the validated input
|
||||
$validated = $validator->validated();
|
||||
|
||||
// Attempt to create the account and emit the event
|
||||
event(new Registered($user = $this->create($validated)));
|
||||
|
||||
// Authenticate the user
|
||||
Auth::guard()->login($user);
|
||||
|
||||
return redirect('user/verification/notice');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the application registration form.
|
||||
*
|
||||
@ -65,16 +95,31 @@ public function showRegistrationForm(): View
|
||||
*
|
||||
* @param Request $request
|
||||
* @return RedirectResponse
|
||||
* @throws ValidationException
|
||||
* @throws \Throwable
|
||||
*/
|
||||
public function register(Request $request)
|
||||
public function register(Request $request): RedirectResponse
|
||||
{
|
||||
$this->validator($request->all())->validate();
|
||||
$validator = $this->validator($request->all());
|
||||
return $this->runRegistrationLogic($validator);
|
||||
}
|
||||
|
||||
event(new Registered($user = $this->create($request->all())));
|
||||
/**
|
||||
* Handle a registration request for the application.
|
||||
*
|
||||
* @param Request $request
|
||||
* @return RedirectResponse
|
||||
* @throws \Throwable
|
||||
*/
|
||||
public function registerFromHeader(Request $request): RedirectResponse
|
||||
{
|
||||
$requestData = $request->all();
|
||||
$validator = $this->validator([
|
||||
'login' => $requestData['header-form-login'] ?? null,
|
||||
'email' => $requestData['header-form-email'] ?? null,
|
||||
'password' => $requestData['header-form-password'] ?? null,
|
||||
'tac' => $requestData['header-form-tac'] ?? null,
|
||||
]);
|
||||
|
||||
Auth::guard()->login($user);
|
||||
|
||||
return redirect('user/verification/notice');
|
||||
return $this->runRegistrationLogic($validator);
|
||||
}
|
||||
}
|
||||
|
31
lang/en/app/register.php
Normal file
31
lang/en/app/register.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'title' => 'Register',
|
||||
'subtitle' => 'Create an account',
|
||||
|
||||
'progress-texts.register' => 'Register',
|
||||
'progress-texts.activate-download' => 'Activate and download',
|
||||
'progress-texts.install-play' => 'Install and play',
|
||||
|
||||
'to-login' => 'or Login',
|
||||
|
||||
'form.username' => 'Username',
|
||||
'form.email' => 'Email',
|
||||
'form.password' => 'Password',
|
||||
'form.password-requirements' => 'Requirements',
|
||||
'form.terms-and-conditions' => 'I have read the [**Terms and Conditions**](:termsUrl) and the [**Privacy Policy**](:privacyUrl) and accept them.',
|
||||
|
||||
'form.password-info.header' => 'A safe password must contain',
|
||||
'form.password-info.rule-1' => 'between 5 and 16 characters',
|
||||
'form.password-info.rule-2' => 'or at least one lowercase letter',
|
||||
'form.password-info.rule-3' => 'at least one uppercase letter',
|
||||
'form.password-info.rule-4' => 'at least one digit',
|
||||
'form.password-info.rule-5' => 'at least one special character',
|
||||
'form.password-info.special-chars' => 'Allowed special characters',
|
||||
|
||||
'form.password-security' => "Your password's security level",
|
||||
'form.required' => '* is required',
|
||||
|
||||
'form.register-btn' => 'Register',
|
||||
];
|
31
lang/ro/app/register.php
Normal file
31
lang/ro/app/register.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'title' => 'Înregistrare',
|
||||
'subtitle' => 'Creează un cont',
|
||||
|
||||
'progress-texts.register' => 'Înregistrare',
|
||||
'progress-texts.activate-download' => 'Activează și descarcă',
|
||||
'progress-texts.install-play' => 'Instalează și joacă-te',
|
||||
|
||||
'to-login' => 'sau Autentifică-te',
|
||||
|
||||
'form.username' => 'Nume de utilizator',
|
||||
'form.email' => 'Email',
|
||||
'form.password' => 'Parola',
|
||||
'form.password-requirements' => 'Reguli parolă',
|
||||
'form.terms-and-conditions' => 'Am citit [**Termenii și Condițiile**](:termsUrl) și [**Politica de Confidențialitate**](:privacyUrl), și le accept.',
|
||||
|
||||
'form.password-info.header' => 'O parolă sigură conține',
|
||||
'form.password-info.rule-1' => 'între 5 și 16 caractere',
|
||||
'form.password-info.rule-2' => 'sau cel puțin o literă mică',
|
||||
'form.password-info.rule-3' => 'cel puțin o literă mare',
|
||||
'form.password-info.rule-4' => 'cel puțin o cifră',
|
||||
'form.password-info.rule-5' => 'cel puțin un caracter special',
|
||||
'form.password-info.special-chars' => 'Caractere speciale permise',
|
||||
|
||||
'form.password-security' => 'Nivelul de securitate al parolei tale',
|
||||
'form.required' => '* este necesar',
|
||||
|
||||
'form.register-btn' => 'Înregistrare',
|
||||
];
|
@ -1,8 +1,8 @@
|
||||
<div id="progressTracker">
|
||||
@php($progressTexts = [
|
||||
1 => 'Înregistrare',
|
||||
2 => 'Activează și descarcă',
|
||||
3 => 'Instalează și joacă-te',
|
||||
1 => __('app/register.progress-texts.register'),
|
||||
2 => __('app/register.progress-texts.activate-download'),
|
||||
3 => __('app/register.progress-texts.install-play'),
|
||||
])
|
||||
|
||||
@for ($i = 1; $i <= 3; $i++)
|
||||
|
@ -6,36 +6,42 @@
|
||||
<div class="content content-last">
|
||||
<div class="content-bg">
|
||||
<div class="content-bg-bottom">
|
||||
<h2>Înregistrarea</h2>
|
||||
<h2>{{ __('app/register.title') }}</h2>
|
||||
|
||||
<x-registration.progress :step="1" />
|
||||
|
||||
<div class="inner-form-border">
|
||||
<div class="inner-form-box">
|
||||
<h3><a id="toLogin" href="{{ url('user/login') }}" title="sau la autentificare">sau la autentificare</a>Creează un cont</h3>
|
||||
<h3>
|
||||
<a id="toLogin" href="{{ url('user/login') }}" title="{{ __('app/register.to-login') }}">{{ __('app/register.to-login') }}</a>
|
||||
{{ __('app/register.title') }}
|
||||
</h3>
|
||||
<div class="trenner"></div>
|
||||
<form name="registerForm" id="registerForm" method="post" action="{{ url('user/register') }}">
|
||||
@csrf
|
||||
|
||||
<div>
|
||||
<label for="username">Nume de utilizator: *</label>
|
||||
<input type="text" class="validate[required,custom[noSpecialCharacters],length[5,16]]" id="username" name="login" title="" value="" maxlength="16"/>
|
||||
<label for="username">{{ __('app/register.form.username') }}: *</label>
|
||||
<input type="text" class="validate[required,custom[noSpecialCharacters],length[5,16]]" id="username" name="login" title="" value="{{ old('login') }}" maxlength="16" />
|
||||
</div>
|
||||
<div>
|
||||
<label for="email">Email: *</label>
|
||||
<input type="text" class="validate[required,custom[email]]" id="email" name="email" maxlength="64" title="" value=""/>
|
||||
<label for="email">{{ __('app/register.form.email') }}: *</label>
|
||||
<input type="text" class="validate[required,custom[email]]" id="email" name="email" maxlength="64" title="" value="{{ old('email') }}" />
|
||||
</div>
|
||||
<div id="pwField">
|
||||
<div id="pwInfo">
|
||||
<h3><img src="{{ asset('assets/main/img/help.gif') }}" alt="Reguli parolă" title="Reguli parolă"/> O parolă sigură să conţină:</h3>
|
||||
<h3>
|
||||
<img src="{{ asset('assets/main/img/help.gif') }}" alt="{{ __('app/register.form.password-requirements') }}" title="{{ __('app/register.form.password-requirements') }}"/>
|
||||
{{ __('app/register.form.password-info.header') }}:
|
||||
</h3>
|
||||
<ul>
|
||||
<li>între 5 și 16 caractere</li>
|
||||
<li>sau cel puțin o literă mică</li>
|
||||
<li>cel puțin o literă mare</li>
|
||||
<li>cel puțin un număr</li>
|
||||
<li>cel puțin un caracter special</li>
|
||||
<li>{{ __('app/register.form.password-info.rule-1') }}</li>
|
||||
<li>{{ __('app/register.form.password-info.rule-2') }}</li>
|
||||
<li>{{ __('app/register.form.password-info.rule-3') }}</li>
|
||||
<li>{{ __('app/register.form.password-info.rule-4') }}</li>
|
||||
<li>{{ __('app/register.form.password-info.rule-5') }}</li>
|
||||
</ul>
|
||||
<p><strong>Caractere speciale permise</strong>:<br/>
|
||||
<p><strong>{{ __('app/register.form.password-info.special-chars') }}</strong>:<br/>
|
||||
@ ! # $ % & ( ) { } * + ,<br/>
|
||||
- . / : ; < > = ? [ ] ^ _ | ~
|
||||
</p>
|
||||
@ -53,13 +59,15 @@
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
<label for="password">Parola: *
|
||||
<span id="toPwInfo" title="Reguli parolă">Reguli parolă <img src="{{ asset('assets/main/img/help.gif') }}" alt="Reguli parolă" title="Reguli parolă"/>
|
||||
</span>
|
||||
<label for="password">{{ __('app/register.form.password') }}: *
|
||||
<span id="toPwInfo" title="{{ __('app/register.form.password-requirements') }}">
|
||||
{{ __('app/register.form.password-requirements') }}
|
||||
<img src="{{ asset('assets/main/img/help.gif') }}" alt="{{ __('app/register.form.password-requirements') }}" title="{{ __('app/register.form.password-requirements') }}" />
|
||||
</span>
|
||||
</label>
|
||||
<input type="password" class="validate[required,custom[onlyValidPasswordCharacters],length[5,16]]" id="password" name="password" maxlength="16" value=""/>
|
||||
<input type="password" class="validate[required,custom[onlyValidPasswordCharacters],length[5,16]]" id="password" name="password" maxlength="16" value="" />
|
||||
<div id="securePwd">
|
||||
<p>Nivelul de securitate al parolei voastre:</p>
|
||||
<p>{{ __('app/register.form.password-security') }}:</p>
|
||||
<div class="valid-icon invalid"></div>
|
||||
<div class="securePwdBarBox">
|
||||
<div id="securePwdBar"></div>
|
||||
@ -69,9 +77,11 @@
|
||||
</div>
|
||||
<div id="checkerror">
|
||||
<input type="checkbox" class="validate[required]" id="tac" name="tac" value="tac"/>
|
||||
<span>Am citit <a href="{{ url('legal/terms') }}" target="_blank"><strong>Termenii și Condițiile</strong></a> și <a href="{{ url('legal/privacy') }}" target="_blank"><strong>Declarația privind protecția datelor</strong></a>. *</span>
|
||||
<span>
|
||||
{!! Str::inlineMarkdown(__('app/register.form.terms-and-conditions', ['termsUrl' => url('legal/terms'), 'privacyUrl' => url('legal/privacy')])) !!} *
|
||||
</span>
|
||||
</div>
|
||||
<input id="submitBtn" type="submit" name="SubmitRegisterForm" value="Înregistrare" class="btn-big"/>
|
||||
<input id="submitBtn" type="submit" value="{{ __('app/register.form.register-btn') }}" class="btn-big"/>
|
||||
|
||||
<script type="text/javascript">
|
||||
@error('login')
|
||||
@ -88,7 +98,7 @@
|
||||
@enderror
|
||||
</script>
|
||||
</form>
|
||||
<p id="regLegend">* este necesar</p>
|
||||
<p id="regLegend">{{ __('app/register.form.required') }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user