Skip to content
Snippets Groups Projects
Commit cd6c6dc2 authored by Jan-Hendrik Willms's avatar Jan-Hendrik Willms Committed by David Siegfried
Browse files

fixes #3678

Closes #3678

Merge request studip/studip!2575
parent c46e214e
No related branches found
No related tags found
No related merge requests found
<?php
use Studip\Forms\Form;
class RegistrationController extends AuthenticatedController
{
protected $allow_nobody = true;
......@@ -14,7 +17,7 @@ class RegistrationController extends AuthenticatedController
{
$new_user = new User();
$this->registrationform = \Studip\Forms\Form::fromSORM(
$this->registrationform = Form::fromSORM(
$new_user,
[
'legend' => _('Herzlich willkommen!'),
......@@ -108,7 +111,7 @@ class RegistrationController extends AuthenticatedController
$this->registrationform->setCancelButtonName(URLHelper::getURL('index.php?cancel_login=1'));
$this->registrationform->addStoreCallback(
function ($form) {
function (Form $form) {
$new_user = $form->getLastPart()->getContextObject();
$GLOBALS['sess']->regenerate_session_id(['auth']);
......
......@@ -318,6 +318,7 @@ class Form extends Part
}
}
}
header('Content-Type: application/json');
echo json_encode($output);
page_close();
die();
......
......@@ -323,11 +323,10 @@ STUDIP.ready(function () {
let v = this;
this.STUDIPFORM_VALIDATIONNOTES = [];
let validation_promise = new Promise(function (resolve, reject) {
return new Promise((resolve, reject) => {
let validated = v.$el.checkValidity();
$(v.$el).find('input, select, textarea').each(function () {
let name = $(this).attr('name');
if (!this.validity.valid) {
let note = {
name: this.name,
......@@ -362,35 +361,30 @@ STUDIP.ready(function () {
v.STUDIPFORM_VALIDATIONNOTES.push(note);
}
});
if (v.STUDIPFORM_SERVERVALIDATION) {
if (v.STUDIPFORM_SERVERVALIDATION) {
let params = v.getFormValues();
if (v.STUDIPFORM_AUTOSAVEURL) {
params.STUDIPFORM_AUTOSTORE = 1;
}
params.STUDIPFORM_SERVERVALIDATION = 1;
$.ajax({
url: v.STUDIPFORM_VALIDATION_URL,
data: params,
type: 'post',
dataType: 'json',
success(output) {
for (let i in output) {
let note = {
name: output[i].name,
label: output[i].label,
description: output[i].error,
describedby: null
};
v.STUDIPFORM_VALIDATIONNOTES.push(note);
}
validated = v.STUDIPFORM_VALIDATIONNOTES.length < 1;
resolve(validated);
$.post(v.STUDIPFORM_VALIDATION_URL, params).done((output) => {
for (let i in output) {
v.STUDIPFORM_VALIDATIONNOTES.push({
name: output[i].name,
label: output[i].label,
description: output[i].error,
describedby: null
});
}
validated = v.STUDIPFORM_VALIDATIONNOTES.length < 1;
resolve(validated);
});
} else {
resolve(validated);
}
});
return validation_promise;
},
setInputs(inputs) {
for (const [key, value] of Object.entries(inputs)) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment