feat: allow invited users to register
Signed-off-by: Miguel Nogueira <me@nogueira.codes>
This commit is contained in:
@@ -28,6 +28,7 @@ use App\User;
|
|||||||
use Illuminate\Foundation\Auth\RegistersUsers;
|
use Illuminate\Foundation\Auth\RegistersUsers;
|
||||||
use Illuminate\Support\Facades\Hash;
|
use Illuminate\Support\Facades\Hash;
|
||||||
use Illuminate\Support\Facades\Validator;
|
use Illuminate\Support\Facades\Validator;
|
||||||
|
use Session;
|
||||||
|
|
||||||
class RegisterController extends Controller
|
class RegisterController extends Controller
|
||||||
{
|
{
|
||||||
@@ -71,6 +72,10 @@ class RegisterController extends Controller
|
|||||||
{
|
{
|
||||||
$password = ['required', 'string', 'confirmed'];
|
$password = ['required', 'string', 'confirmed'];
|
||||||
|
|
||||||
|
$signupEnabled = Options::getOption('enable_registrations');
|
||||||
|
$signupOverride = Session::has('ALLOW_REGISTRATION_OVERRIDE') && Session::get('ALLOW_REGISTRATION_OVERRIDE') === true;
|
||||||
|
$signupOverrideEmail = Session::has('REGISTRATION_OVERRIDE_EMAIL') ? Session::get('REGISTRATION_OVERRIDE_EMAIL') : null;
|
||||||
|
|
||||||
switch (Options::getOption('pw_security_policy')) { // this could be better structured, switch doesn't feel right
|
switch (Options::getOption('pw_security_policy')) { // this could be better structured, switch doesn't feel right
|
||||||
case 'off':
|
case 'off':
|
||||||
$password = ['required', 'string', 'confirmed'];
|
$password = ['required', 'string', 'confirmed'];
|
||||||
@@ -99,7 +104,15 @@ class RegisterController extends Controller
|
|||||||
'dob.required' => __('Please enter your date of birth.'),
|
'dob.required' => __('Please enter your date of birth.'),
|
||||||
'uuid.required' => __('Please enter a valid (and Premium) Minecraft username! We do not support cracked users.'),
|
'uuid.required' => __('Please enter a valid (and Premium) Minecraft username! We do not support cracked users.'),
|
||||||
'acceptTerms.required' => __('Please accept the Community Guidelines, Terms of Service and Privacy Policy to continue.'),
|
'acceptTerms.required' => __('Please accept the Community Guidelines, Terms of Service and Privacy Policy to continue.'),
|
||||||
]);
|
|
||||||
|
])->after(function (\Illuminate\Validation\Validator $validator) use ($signupEnabled, $signupOverride, $signupOverrideEmail) {
|
||||||
|
|
||||||
|
$email = $validator->getData()['email'];
|
||||||
|
|
||||||
|
$validator->errors()->addIf(!$signupEnabled && !$signupOverride, 'signup', __('We\'re sorry, but new sign ups are currently closed and invite-only.'));
|
||||||
|
$validator->errors()->addIf($signupOverride && $email !== $signupOverrideEmail, 'email', 'You must sign up with the email address you were invited with.');
|
||||||
|
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -124,6 +137,13 @@ class RegisterController extends Controller
|
|||||||
|
|
||||||
$user->assignRole('user');
|
$user->assignRole('user');
|
||||||
|
|
||||||
|
if (Session::get('ALLOW_REGISTRATION_OVERRIDE')) {
|
||||||
|
Session::forget([
|
||||||
|
'ALLOW_REGISTRATION_OVERRIDE',
|
||||||
|
'REGISTRATION_OVERRIDE_EMAIL'
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
return $user;
|
return $user;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -14,9 +14,17 @@
|
|||||||
<img src="{{ asset(config('adminlte.logo_img_xl')) }}" alt="logo" class="logo rounded mr-2">
|
<img src="{{ asset(config('adminlte.logo_img_xl')) }}" alt="logo" class="logo rounded mr-2">
|
||||||
</div> <!-- main content start -->
|
</div> <!-- main content start -->
|
||||||
|
|
||||||
@if(\App\Facades\Options::getOption('enable_registrations') == true)
|
@if(\App\Facades\Options::getOption('enable_registrations') == true || session()->has('ALLOW_REGISTRATION_OVERRIDE'))
|
||||||
<p class="login-card-description">{{__('Sign up for an account')}}</p>
|
<p class="login-card-description">{{__('Sign up for an account')}}</p>
|
||||||
|
|
||||||
|
@if(session()->has('ALLOW_REGISTRATION_OVERRIDE') && session('ALLOW_REGISTRATION_OVERRIDE') === true)
|
||||||
|
<div class="alert alert-info">
|
||||||
|
<strong><i class="fas fa-info-circle"></i> {{ __('Invite only registration') }}</strong>
|
||||||
|
<p>{{ __('You are signing up with an invitation. Please use the original email address you were invited with to complete your registration. Any other email address will not work.') }}</p>
|
||||||
|
<p>{{ __('If you close the browser or otherwise clear your cookies, this page will NOT be available again if registrations are still closed.') }}</p>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
@if(\App\Facades\Options::getOption('pw_security_policy') !== 'off')
|
@if(\App\Facades\Options::getOption('pw_security_policy') !== 'off')
|
||||||
|
|
||||||
<div class="alert alert-warning alert-dismissible">
|
<div class="alert alert-warning alert-dismissible">
|
||||||
|
Reference in New Issue
Block a user