Update registration form

2022-03-24
Luca 3 years ago
parent 633e36b5f3
commit 08d6f8e3e5

@ -258,9 +258,6 @@ return [
// Whether the DECT field should be enabled // Whether the DECT field should be enabled
'enable_dect' => (bool)env('ENABLE_DECT', false), 'enable_dect' => (bool)env('ENABLE_DECT', false),
// Enables prename and lastname
'enable_user_name' => (bool)env('ENABLE_USER_NAME', true),
// Enable displaying the pronoun fields // Enable displaying the pronoun fields
'enable_pronoun' => (bool)env('ENABLE_PRONOUN', false), 'enable_pronoun' => (bool)env('ENABLE_PRONOUN', false),
@ -270,12 +267,12 @@ return [
// Enables the T-Shirt configuration on signup and profile // Enables the T-Shirt configuration on signup and profile
'enable_tshirt_size' => (bool)env('ENABLE_TSHIRT_SIZE', false), 'enable_tshirt_size' => (bool)env('ENABLE_TSHIRT_SIZE', false),
// Enables the goody/voucher configuration on signup and profile
'enable_goody' => (bool)env('ENABLE_GOODY', false),
// Enables shifts export as iCal/JSON (if disabled, buttons/links will not be shown, but endpoints will still work) // Enables shifts export as iCal/JSON (if disabled, buttons/links will not be shown, but endpoints will still work)
'enable_shifts_export' => (bool)env('ENABLE_SHIFTS_EXPORT', false), 'enable_shifts_export' => (bool)env('ENABLE_SHIFTS_EXPORT', false),
// Enables joining angel types on registration
'enable_angeltype_signup' => (bool)env('ENABLE_ANGELTYPE_SIGNUP', false),
// Number of shifts to freeload until angel is locked for shift signup. // Number of shifts to freeload until angel is locked for shift signup.
'max_freeloadable_shifts' => env('MAX_FREELOADABLE_SHIFTS', 1), 'max_freeloadable_shifts' => env('MAX_FREELOADABLE_SHIFTS', 1),

@ -28,29 +28,24 @@ function guest_register()
$authUser = auth()->user(); $authUser = auth()->user();
$tshirt_sizes = config('tshirt_sizes'); $tshirt_sizes = config('tshirt_sizes');
$enable_tshirt_size = config('enable_tshirt_size'); $enable_tshirt_size = config('enable_tshirt_size');
$enable_user_name = config('enable_user_name');
$enable_dect = config('enable_dect'); $enable_dect = config('enable_dect');
$enable_planned_arrival = config('enable_planned_arrival'); $enable_planned_arrival = config('enable_planned_arrival');
$min_password_length = config('min_password_length'); $min_password_length = config('min_password_length');
$enable_password = config('enable_password'); $enable_password = config('enable_password');
$enable_pronoun = config('enable_pronoun'); $enable_pronoun = config('enable_pronoun');
$enable_angeltype_signup = config('enable_angeltype_signup');
$config = config(); $config = config();
$request = request(); $request = request();
$session = session(); $session = session();
$is_oauth = $session->has('oauth2_connect_provider'); $is_oauth = $session->has('oauth2_connect_provider');
$msg = ''; $msg = '';
$nick = '';
$lastName = ''; $lastName = '';
$preName = ''; $preName = '';
$dect = ''; $dect = '';
$mobile = ''; $mobile = '';
$email = '';
$pronoun = ''; $pronoun = '';
$email_shiftinfo = false; $mobile_consent = false;
$email_by_human_allowed = false;
$email_news = false;
$email_goody = false;
$tshirt_size = ''; $tshirt_size = '';
$password_hash = ''; $password_hash = '';
$selected_angel_types = []; $selected_angel_types = [];
@ -97,53 +92,37 @@ function guest_register()
if ($request->hasPostData('submit')) { if ($request->hasPostData('submit')) {
$valid = true; $valid = true;
if ($request->has('username')) { if ($request->has('prename')) {
$nickValidation = User_validate_Nick($request->input('username')); $preName = strip_request_item('prename');
$nick = $nickValidation->getValue();
if (!$nickValidation->isValid()) {
$valid = false;
$msg .= error(sprintf(__('Please enter a valid nick.') . ' ' . __('Use up to 24 letters, numbers, connecting punctuations or spaces for your nickname.'),
$nick), true);
}
if (User::whereName($nick)->count() > 0) {
$valid = false;
$msg .= error(sprintf(__('Your nick "%s" already exists.'), $nick), true);
}
} else { } else {
$valid = false; $valid = false;
$msg .= error(__('Please enter a nickname.'), true); $msg .= error(__('Please enter your first name.'), true);
} }
if ($request->has('email') && strlen(strip_request_item('email')) > 0) { if ($request->has('lastname')) {
$email = strip_request_item('email'); $lastName = strip_request_item('lastname');
if (!check_email($email)) {
$valid = false;
$msg .= error(__('E-mail address is not correct.'), true);
}
if (User::whereEmail($email)->first()) {
$valid = false;
$msg .= error(__('E-mail address is already used by another user.'), true);
}
} else { } else {
$valid = false; $valid = false;
$msg .= error(__('Please enter your e-mail.'), true); $msg .= error(__('Please enter your last name.'), true);
} }
if ($request->has('email_shiftinfo')) { if ($request->has('mobile')) {
$email_shiftinfo = true; $mobile = strip_request_item('mobile');
}
if ($request->has('email_by_human_allowed')) { if (User::whereName($mobile)->count() > 0) {
$email_by_human_allowed = true; $valid = false;
$msg .= error(__('This mobile number is already in use.'), true);
} }
} else {
if ($request->has('email_news')) { $valid = false;
$email_news = true; $msg .= error(__('Please enter your mobile number.'), true);
} }
if ($request->has('email_goody')) { if ($request->has('mobile_consent')) {
$email_goody = true; $mobile_consent = true;
} else {
$valid = false;
$msg .= error(__('Please consent to receiving notifications via SMS.'), true);
} }
if ($enable_tshirt_size) { if ($enable_tshirt_size) {
@ -189,12 +168,6 @@ function guest_register()
} }
// Trivia // Trivia
if ($enable_user_name && $request->has('lastname')) {
$lastName = strip_request_item('lastname');
}
if ($enable_user_name && $request->has('prename')) {
$preName = strip_request_item('prename');
}
if ($enable_pronoun && $request->has('pronoun')) { if ($enable_pronoun && $request->has('pronoun')) {
$pronoun = strip_request_item('pronoun'); $pronoun = strip_request_item('pronoun');
} }
@ -206,15 +179,12 @@ function guest_register()
error(__('For dect numbers are only 40 digits allowed.')); error(__('For dect numbers are only 40 digits allowed.'));
} }
} }
if ($request->has('mobile')) {
$mobile = strip_request_item('mobile');
}
if ($valid) { if ($valid) {
$user = new User([ $user = new User([
'name' => $nick, 'name' => $mobile,
'password' => $password_hash, 'password' => $password_hash,
'email' => $email, 'email' => $mobile,
'api_key' => '', 'api_key' => '',
'last_login_at' => null, 'last_login_at' => null,
]); ]);
@ -242,10 +212,10 @@ function guest_register()
$settings = new Settings([ $settings = new Settings([
'language' => $session->get('locale'), 'language' => $session->get('locale'),
'theme' => config('theme'), 'theme' => config('theme'),
'email_human' => $email_by_human_allowed, 'email_human' => $mobile_consent,
'email_goody' => $email_goody, 'email_goody' => $mobile_consent,
'email_shiftinfo' => $email_shiftinfo, 'email_shiftinfo' => $mobile_consent,
'email_news' => $email_news, 'email_news' => $mobile_consent,
]); ]);
$settings->user() $settings->user()
->associate($user) ->associate($user)
@ -336,14 +306,6 @@ function guest_register()
$form_data = $session->get('form_data'); $form_data = $session->get('form_data');
$session->remove('form_data'); $session->remove('form_data');
if (!$nick && !empty($form_data['name'])) {
$nick = $form_data['name'];
}
if (!$email && !empty($form_data['email'])) {
$email = $form_data['email'];
}
if (!$preName && !empty($form_data['first_name'])) { if (!$preName && !empty($form_data['first_name'])) {
$preName = $form_data['first_name']; $preName = $form_data['first_name'];
} }
@ -360,79 +322,39 @@ function guest_register()
form([ form([
div('row', [ div('row', [
div('col', [ div('col', [
form_text( form_text('prename', __('First name') . ' ' . entry_required(), $preName, false, 64, 'given-name')
'username',
__('Nick') . ' ' . entry_required(),
$nick,
false,
24,
'nickname'
),
form_info('',
__('Use up to 24 letters, numbers, connecting punctuations or spaces for your nickname.'))
]), ]),
div('col', [
form_text('lastname', __('Last name') . ' ' . entry_required(), $lastName, false, 64, 'family-name')
])
$enable_pronoun ? div('col', [ $enable_pronoun ? div('col', [
form_text('pronoun', __('Pronoun'), $pronoun, false, 15) form_text('pronoun', __('Pronoun'), $pronoun, false, 15)
]) : '', ]) : '',
]), ]),
$enable_user_name ? div('row', [
div('col', [
form_text('prename', __('First name'), $preName, false, 64, 'given-name')
]),
div('col', [
form_text('lastname', __('Last name'), $lastName, false, 64, 'family-name')
])
]) : '',
div('row', [ div('row', [
div('col', [ div('col', [
form_email( form_text(
'email', 'mobile',
__('E-Mail') . ' ' . entry_required(), __('Mobile'),
$email, $mobile,
false, false,
'email', 40,
254 'tel-national'
),
form_checkbox(
'email_shiftinfo',
__(
'The %s is allowed to send me an email (e.g. when my shifts change)',
[config('app_name')]
),
$email_shiftinfo
),
form_checkbox(
'email_news',
__('Notify me of new news'),
$email_news
), ),
form_checkbox( form_checkbox(
'email_by_human_allowed', 'mobile_consent',
__('Allow heaven angels to contact you by e-mail.'), __('I consent to receive notifications via SMS.') . ' ' . entry_required(),
$email_by_human_allowed $mobile_consent
), ),
config('enable_goody') ?
form_checkbox(
'email_goody',
__('To receive vouchers, give consent that nick, email address, worked hours and shirt size will be stored until the next similar event.')
. (config('privacy_email') ? ' ' . __('To withdraw your approval, send an email to <a href="mailto:%s">%1$s</a>.', [config('privacy_email')]) : ''),
$email_goody
) : '',
]), ]),
$enable_dect ? div('col', [ $enable_dect ? div('col', [
form_text('dect', __('DECT'), $dect, false, 40, 'tel-local') form_text('dect', __('DECT'), $dect, false, 40, 'tel-local')
]) : '', ]) : '',
div('col', [
form_text('mobile', __('Mobile'), $mobile, false, 40, 'tel-national')
])
]), ]),
div('row', [ $enable_password || $enable_planned_arrival ? div('row', [
$enable_password ? div('col', [ $enable_password ? div('col', [
form_password('password', __('Password') . ' ' . entry_required()) form_password('password', __('Password') . ' ' . entry_required())
]) : '', ]) : '',
@ -444,21 +366,22 @@ function guest_register()
$planned_arrival_date, $buildup_start_date, $teardown_end_date $planned_arrival_date, $buildup_start_date, $teardown_end_date
) )
]) : '', ]) : '',
]), ]) : '',
div('row', [ $enable_password || $enable_tshirt_size ? div('row', [
$enable_password ? div('col', [ $enable_password ? div('col', [
form_password('password2', __('Confirm password') . ' ' . entry_required()) form_password('password2', __('Confirm password') . ' ' . entry_required())
]) : '', ]) : '',
div('col', [ $enable_tshirt_size ? div('col', [
$enable_tshirt_size ? form_select('tshirt_size', form_select('tshirt_size',
__('Shirt size') . ' ' . entry_required(), __('Shirt size') . ' ' . entry_required(),
$tshirt_sizes, $tshirt_size, __('Please select...')) : '' $tshirt_sizes, $tshirt_size, __('Please select...')
]), )
]), ]) : '',
]) : '',
div('row', [ $enable_angeltype_signup ? div('row', [
div('col', [ div('col', [
form_checkboxes( form_checkboxes(
'angel_types', 'angel_types',
@ -475,7 +398,7 @@ function guest_register()
__('Some angel types have to be confirmed later by a supporter at an introduction meeting. You can change your selection in the options section.') __('Some angel types have to be confirmed later by a supporter at an introduction meeting. You can change your selection in the options section.')
) )
]) ])
]), ]) : '',
form_submit('submit', __('Register')) form_submit('submit', __('Register'))
]) ])

Loading…
Cancel
Save