Commit 43f50c63 authored by Matthias Larisch's avatar Matthias Larisch

Request birthdate and age 18+ on registration

parent 934d379e
Pipeline #22459057 passed with stages
in 10 minutes and 59 seconds
......@@ -8,6 +8,7 @@
- decreased distance to "close baskets" from 50 to 30 km. !332 #338 by @peter.toennies
- sort fairtiler list by name. !357 #171 by @k.miklobusec
- Store Managers business card creation for region. Remove country card. !76 by @k.miklobusec
- Registered users need to fill their birthday and be 18+ for data protection and liability reasons. !377 @NerdyProjects
## Bugfixes
- Remove info section from foodsaver page, if it is empty !320
......
......@@ -62,7 +62,7 @@ var join = {
})
},
finish: function(){
if($('#join_legal1:checked').length <= 0)
{
pulseError('Bitte akzeptiere unsere Datenschutzerkl&auml;rung');
......@@ -77,7 +77,7 @@ var join = {
{
$('#joinform').hide();
$('#joinloader').show();
$.ajax({
url: '/xhrapp.php?app=login&m=joinsubmit',
type:'post',
......@@ -88,6 +88,7 @@ var join = {
surname:$('#login_surname').val(),
email:$('#login_email').val(),
pw:$('#login_passwd1').val(),
birthdate:$('#birthdate').val(),
avatar:$('#join_avatar').val(),
phone:$('#login_phone').val(),
lat:$('#join_lat').val(),
......@@ -115,12 +116,12 @@ var join = {
}
}
});
}
},
step: function(step)
{
if(join.currentStep >= step || join.stepCheck(step))
{
switch(step)
......@@ -128,11 +129,11 @@ var join = {
case 2:
join.loadMap();
break;
default:
break;
}
$('.step').hide();
$('.step'+step).show();
$('.linklist.join li').removeClass('active').children('a').children('i').remove();
......@@ -157,7 +158,7 @@ var join = {
return false;
check = false;
}
if(!checkEmail($('#login_email').val()))
{
pulseError('Mit Deiner E-Mail-Adresse stimmt etwas nicht');
......@@ -165,7 +166,22 @@ var join = {
return false;
check = false;
}
let birthdate = new Date($('#birthdate').val());
let now = new Date();
let diff = now.getFullYear() - birthdate.getFullYear();
if(birthdate.getMonth() > now.getMonth()) {
diff--;
} else {
if(birthdate.getMonth() == now.getMonth()) {
if (birthdate.getDay() > now.getDay())
diff--;
}
}
if(diff<18) {
pulseInfo('Aus datenschutz- und haftungsrechtlichen Gründen musst du mindestens 18 Jahre alt sein, um bei foodsharing.de mitzumachen.')
return false;
}
if($('#login_passwd1').val().length < 4) // || $('#login_passwd1').val() != $('#login_passwd2').val())
{
pulseInfo('Dein Passwort muss länger als 4 Buchstaben sein');
......@@ -173,7 +189,7 @@ var join = {
return false;
check = false;
}
if($('#login_passwd1').val() != $('#login_passwd2').val())
{
pulseInfo('Deine Passwörter stimmen nicht überein');
......@@ -181,14 +197,14 @@ var join = {
return false;
check = false;
}
if(join.isLoading)
{
pulseInfo('Bitte warte bis Dein Foto hochgeladen ist');
return false;
check = false;
}
if($('#join_avatar_error').val() == '0' && $('#join_avatar').val() == '')
{
if(!confirm('Du hast kein Foto hochgeladen. Beachte, dass ein passbildähnliches Foto benötigt wird, wenn du später auch als Foodsaver aktiv werden möchtest. Ohne Foto fortfahren?'))
......@@ -197,7 +213,7 @@ var join = {
check = false;
}
}
if(check)
{
return true;
......@@ -206,9 +222,9 @@ var join = {
{
return false;
}
break;
default:
return true;
break;
......
......@@ -14,6 +14,7 @@ $g_lang['contact_info'] = 'Kontaktinformationen';
$g_lang['legal_stuff'] = 'Rechtliches';
$g_lang['select_picture'] = 'Foto ausw&auml;hlen';
$g_lang['peer'] = 'Foodsharer';
$g_lang['geb_datum'] = 'Geburtsdatum';
$g_lang['organisation'] = 'Organisation';
$g_lang['login_phone'] = 'Telefonnummer';
$g_lang['login_location'] = 'Deine Adresse';
......@@ -36,6 +37,7 @@ $g_lang['error_name'] = 'Bitte gib einen Namen ein';
$g_lang['error_email'] = 'Mit Deiner E-Mail-Adresse stimmt etwas nicht';
$g_lang['error_passwd'] = 'Dein Passwort muss mindestens 5 und darf maximal 30 Zeichen haben';
$g_lang['error_image'] = 'Dein Foto konnte nicht hochgeladen werden';
$g_lang['error_birthdate'] = 'Aus datenschutz- und haftungsrechtlichen Gründen musst du mindestens 18 Jahre alt sein, um bei foodsharing.de mitzumachen.';
$g_lang['activation_success'] = '<strong>Aktivierung erfolgreich.</strong> Logge Dich jetzt Mit Deiner E-Mail-Adresse und Deinem gewählten Passwort ein.';
$g_lang['activation_failed'] = '<strong>Aktivierung fehlgeschlagen!</strong> Ist der eingegebene Link auch korrekt?';
......
......@@ -44,6 +44,7 @@ class LoginModel extends Model
`name`,
`nachname`,
`anschrift`,
`geb_datum`,
`telefon`,
`newsletter`,
`geschlecht`,
......@@ -65,6 +66,7 @@ class LoginModel extends Model
' . $this->strval($data['name']) . ',
' . $this->strval($data['surname']) . ',
' . $this->strval($data['str'] . ' ' . trim($data['nr'])) . ',
' . $this->strval($data['birthdate']) . ',
' . $this->strval($data['phone']) . ',
' . $this->intval($data['newsletter']) . ',
' . $this->intval($data['gender']) . ',
......
......@@ -76,14 +76,17 @@ class LoginView extends View
<div class="element-wrapper">
<input placeholder="' . $this->func->s('login_passwd2') . '" type="password" value="" id="login_passwd2" name="login_passwd1" class="input text value" />
</div>
<div class="element-wrapper">
<input type="date" id="birthdate" min="' . date('Y-m-d', strtotime('-120 years')) . '" max="' . date('Y-m-d', strtotime('-18 years')) . '" required />
<label for="birthdate">' . $this->func->s('geb_datum') . '</label>
</div>
</div>
<div class="avatar">
<form action="/xhrapp.php?app=login&m=photoupload" id="join_photoform" target="join_upload_frame" method="post" enctype="multipart/form-data">
<input type="hidden" name="action" value="upload" />
<a onclick="$(\'#join_photo\').trigger(\'click\');return false;" class="container corner-all" href="#">
<span class="mega-octicon octicon-device-camera"></span>
<span class="fa fa-circle-o-notch fa-spin"></span>
<span class="fa fa-circle-o-notch fa-spin"></span>
</a><br />
<a onclick="$(\'#join_photo\').trigger(\'click\');return false;" href="#" class="button">' . $this->func->s('select_picture') . '</a><span class="filewrapper"><input onchange="join.startUpload();" type="file" name="photo" id="join_photo" /></span>
</form>
......
......@@ -240,7 +240,13 @@ class LoginXhr extends Control
if ($data['gender'] > 2 || $data['gender'] < 0) {
$data['gender'] = 0;
}
$birthdate = \DateTime::createFromFormat('Y-m-d', $data['birthdate']);
$min_birthdate = new \DateTime();
$min_birthdate->modify('-18 years');
if (!$birthdate || $birthdate > $min_birthdate) {
return $this->func->s('error_birthdate');
}
$data['birthdate'] = $birthdate->format('Y-m-d');
$data['phone'] = $this->format_phone_number($data['phone']);
$data['lat'] = floatval($data['lat']);
$data['lon'] = floatval($data['lon']);
......
......@@ -15,6 +15,7 @@ class RegisterCest
$this->first_name = sq('first_name');
$this->last_name = sq('last_name');
$this->password = sq('password');
$this->birthdate = '1991-04-27';
}
public function _after()
......@@ -44,6 +45,8 @@ class RegisterCest
$I->fillField('login_name', $this->first_name);
$I->fillField('login_surname', $this->last_name);
$I->fillField('login_email', $this->email);
/* workaround because chromedriver fails to fill a date field... */
$I->executeJS("document.querySelector('#birthdate').value = '" . $this->birthdate . "'");
$I->fillField('#login_passwd1', $this->password);
$I->fillField('#login_passwd2', $this->password);
$I->click('weiter', '.step.step1');
......@@ -86,6 +89,7 @@ class RegisterCest
'email' => $this->stripped_email,
'name' => $this->first_name,
'nachname' => $this->last_name,
'geb_datum' => $this->birthdate,
'newsletter' => 0
]);
}
......
......@@ -8,6 +8,7 @@ $email = sq('email') . '@test.com';
$first_name = sq('first_name');
$last_name = sq('last_name');
$pass = sq('pass');
$birthdate = '1990-05-31';
$I->haveHttpHeader('Content-Type', 'application/x-www-form-urlencoded');
......@@ -19,6 +20,7 @@ $I->sendPOST('/xhrapp.php?app=login&m=joinsubmit', [
'phone' => '39833',
'pw' => $pass,
'gender' => 0,
'birthdate' => $birthdate,
'newsletter' => 1
]);
......@@ -31,7 +33,7 @@ $I->seeInDatabase('fs_foodsaver', [
'name' => $first_name,
'nachname' => $last_name,
'newsletter' => 1,
'geb_datum' => $birthdate,
'passwd' => null, // no md5 password
'fs_password' => null, // no sha1 password
]);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment