1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
|
<?php
use Studip\Forms\Form;
class RegistrationController extends AuthenticatedController
{
protected $allow_nobody = true;
public function before_filter(&$action, &$args)
{
parent::before_filter($action, $args);
PageLayout::setTitle(_('Registrierung'));
}
public function index_action()
{
$new_user = new User();
$new_user->perms = 'user';
$new_user->auth_plugin = 'standard';
$new_user->preferred_language = $_SESSION['_language'] ?? Config::get()->DEFAULT_LANGUAGE;
$this->registrationform = Form::fromSORM(
$new_user,
[
'legend' => _('Herzlich willkommen!'),
'fields' => [
'username' => [
'label' => _('Benutzername'),
'required' => true,
'maxlength' => '63',
'attributes' => ['autocomplete' => 'off'],
'validate' => function ($value, $input) {
if (!preg_match(Config::get()->USERNAME_REGULAR_EXPRESSION, $value)) {
return Config::get()->getMetadata('USERNAME_REGULAR_EXPRESSION')['comment'] ?:
_('Benutzername muss mindestens 4 Zeichen lang sein und darf nur aus Buchstaben, '
. 'Ziffern, Unterstrich, @, Punkt und Minus bestehen.');
}
$user = User::findByUsername($value);
$context = $input->getContextObject();
if ($user && ($user->id !== $context->getId())) {
return _('Benutzername ist schon vergeben.');
}
return true;
}
],
'password' => [
'label' => _('Passwort'),
'type' => 'password',
'required' => true,
'maxlength' => '31',
'minlength' => '8',
'attributes' => ['autocomplete' => 'new-password'],
'mapper' => function($value) {
$hasher = UserManagement::getPwdHasher();
return $hasher->HashPassword($value);
}
],
'confirm_password' => [
'label' => _('Passwortbestätigung'),
'type' => 'password',
'required' => true,
'maxlength' => '31',
'minlength' => '8',
'attributes' => ['autocomplete' => 'new-password'],
':pattern' => "password.replace(/[.*+?^\${}()|[\\]\\\\]/g, '\\\\$&')", //mask special chars
'data-validation_requirement' => _('Passwörter stimmen nicht überein.'),
'store' => function() {}
],
'title_front' => [
'label' => _('Titel'),
'type' => 'datalist',
'attributes' => ['autocomplete' => 'honorific-prefix'],
'options' => $GLOBALS['TITLE_FRONT_TEMPLATE']
],
'title_rear' => [
'label' => _('Titel nachgestellt'),
'type' => 'datalist',
'attributes' => ['autocomplete' => 'honorific-suffix'],
'options' => $GLOBALS['TITLE_REAR_TEMPLATE'],
],
'vorname' => [
'label' => _('Vorname'),
'attributes' => ['autocomplete' => 'given-name'],
'required' => true
],
'nachname' => [
'label' => _('Nachname'),
'attributes' => ['autocomplete' => 'family-name'],
'required' => true
],
'geschlecht' => [
'name' => 'geschlecht',
'value' => 0,
'label' => _('Geschlecht'),
'type' => 'radio',
'orientation' => 'horizontal',
'options' => [
'0' => _('keine Angabe'),
'1' => _('männlich'),
'2' => _('weiblich'),
'3' => _('divers'),
],
],
'email' => [
'label' => _('E-Mail'),
'required' => true,
'attributes' => ['autocomplete' => 'email'],
'validate' => function ($value, $input) {
$user = User::findOneByEmail($value);
$context = $input->getContextObject();
if ($user && ($user->id !== $context->getId())) {
return _('Diese Emailadresse ist bereits registriert.');
}
return true;
}
],
]
]
);
$this->registrationform->setSaveButtonText(_('Registrierung abschließen'));
$this->registrationform->setCancelButtonText(_('Abbrechen'));
$this->registrationform->setCancelButtonName(URLHelper::getURL('index.php?cancel_login=1'));
$this->registrationform->addStoreCallback(
function (Form $form) {
$new_user = $form->getLastPart()->getContextObject();
$GLOBALS['sess']->regenerate_session_id(['auth']);
$GLOBALS['auth']->unauth();
$GLOBALS['auth']->auth['jscript'] = true;
$GLOBALS['auth']->auth['perm'] = $new_user['perms'];
$GLOBALS['auth']->auth['uname'] = $new_user['username'];
$GLOBALS['auth']->auth['auth_plugin'] = $new_user['auth_plugin'];
$GLOBALS['auth']->auth_set_user_settings($new_user->user_id);
$GLOBALS['auth']->auth['uid'] = $new_user['user_id'];
Seminar_Register_Auth::sendValidationMail($new_user);
return 1;
}
);
$this->registrationform->autoStore()->setURL(URLHelper::getURL('dispatch.php/start'));
}
}
|