[mod] page:register
This commit is contained in:
parent
0f7f671341
commit
b02584b128
3 changed files with 67 additions and 11 deletions
12
source/data/localization/deu.loc.json
Normal file
12
source/data/localization/deu.loc.json
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
{
|
||||||
|
"meta": {
|
||||||
|
"identifier": "deu"
|
||||||
|
},
|
||||||
|
"tree": {
|
||||||
|
"register.flaw.password_too_short": "das Passwort muss mindestens {{minimum_length}} Zeichen haben",
|
||||||
|
"register.flaw.password_too_long": "das Passwort darf höchstens {{maximum_length}} Zeichen haben",
|
||||||
|
"register.flaw.password_lacks_letter": "das Passwort muss einen Buchstaben beinhalten",
|
||||||
|
"register.flaw.password_lacks_number": "das Passwort muss ein Zahl beinhalten",
|
||||||
|
"register.flaw.password_lacks_special_character": "das Passwort muss ein Sonderzeichen beinhalten"
|
||||||
|
}
|
||||||
|
}
|
|
@ -44,12 +44,14 @@ namespace _espe.backend
|
||||||
path : string,
|
path : string,
|
||||||
options : {
|
options : {
|
||||||
data ?: type_input;
|
data ?: type_input;
|
||||||
|
custom_response_handlers ?: Record<int, ((output_data_raw : any) => Promise<type_output>)>;
|
||||||
} = {}
|
} = {}
|
||||||
) : Promise<type_output>
|
) : Promise<type_output>
|
||||||
{
|
{
|
||||||
options = Object.assign(
|
options = Object.assign(
|
||||||
{
|
{
|
||||||
"data": null,
|
"data": null,
|
||||||
|
"custom_response_handlers": [],
|
||||||
},
|
},
|
||||||
options
|
options
|
||||||
);
|
);
|
||||||
|
@ -91,11 +93,16 @@ namespace _espe.backend
|
||||||
)
|
)
|
||||||
.then(
|
.then(
|
||||||
x => {
|
x => {
|
||||||
if ((x.status >= 200) && (x.status < 300)) {
|
if (x.status in options.custom_response_handlers) {
|
||||||
return x.json();
|
return x.json().then(output_data_raw => options.custom_response_handlers[x.status](output_data_raw));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return Promise.reject<type_output>(new Error("unexpected response status code"));
|
if ((x.status >= 200) && (x.status < 300)) {
|
||||||
|
return x.json();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return Promise.reject<type_output>(new Error("irregular response status code"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -327,7 +334,14 @@ namespace _espe.backend
|
||||||
email_redirect_to_private_address : boolean;
|
email_redirect_to_private_address : boolean;
|
||||||
password : (null | string);
|
password : (null | string);
|
||||||
}
|
}
|
||||||
) : Promise<void>
|
) : Promise<
|
||||||
|
Array<
|
||||||
|
{
|
||||||
|
incident : string;
|
||||||
|
details : Record<string, any>;
|
||||||
|
}
|
||||||
|
>
|
||||||
|
>
|
||||||
{
|
{
|
||||||
return (
|
return (
|
||||||
abstract_call(
|
abstract_call(
|
||||||
|
@ -341,6 +355,9 @@ namespace _espe.backend
|
||||||
),
|
),
|
||||||
{
|
{
|
||||||
"data": data,
|
"data": data,
|
||||||
|
"custom_response_handlers": {
|
||||||
|
409: (output_data_raw) => output_data_raw,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
|
@ -3,11 +3,20 @@ lib_plankton.zoo_page.register(
|
||||||
async (parameters, target_element) => {
|
async (parameters, target_element) => {
|
||||||
function set_state(
|
function set_state(
|
||||||
state : ("load" | "fill" | "wait" | "done"),
|
state : ("load" | "fill" | "wait" | "done"),
|
||||||
message : (null | string) = null
|
messages : Array<string> = []
|
||||||
) : void
|
) : void
|
||||||
{
|
{
|
||||||
target_element.querySelector(".register").setAttribute("rel", state);
|
target_element.querySelector(".register").setAttribute("rel", state);
|
||||||
target_element.querySelector(".register-message").textContent = (message ?? "");
|
target_element.querySelector(".register-message").textContent = "";
|
||||||
|
let dom_list = document.createElement("ul");
|
||||||
|
messages.forEach(
|
||||||
|
message => {
|
||||||
|
let dom_message = document.createElement("li");
|
||||||
|
dom_message.textContent = message;
|
||||||
|
dom_list.appendChild(dom_message);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
target_element.querySelector(".register-message").appendChild(dom_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
const id : int = parseInt(parameters["id"]);
|
const id : int = parseInt(parameters["id"]);
|
||||||
|
@ -113,13 +122,13 @@ lib_plankton.zoo_page.register(
|
||||||
password_confirmation : string;
|
password_confirmation : string;
|
||||||
} = await input.read();
|
} = await input.read();
|
||||||
if (value.password_value !== value.password_confirmation) {
|
if (value.password_value !== value.password_confirmation) {
|
||||||
alert("Die Passwörter stimmen nicht überein");
|
set_state("fill", ["Die Passwörter stimmen nicht überein"]);
|
||||||
set_state("fill");
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
set_state("wait");
|
set_state("wait");
|
||||||
|
let flaws : Array<{incident : string; details : Record<string, any>;}>;
|
||||||
try {
|
try {
|
||||||
await _espe.backend.member_register(
|
flaws = await _espe.backend.member_register(
|
||||||
id,
|
id,
|
||||||
verification,
|
verification,
|
||||||
{
|
{
|
||||||
|
@ -131,9 +140,27 @@ lib_plankton.zoo_page.register(
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
set_state("fill", "Da ist etwas schief gelaufen :/");
|
flaws = [
|
||||||
|
{"incident": "unhandled_error", "details": {}},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
if (flaws.length > 0) {
|
||||||
|
set_state(
|
||||||
|
"fill",
|
||||||
|
flaws.map(
|
||||||
|
flaw => lib_plankton.string.coin(
|
||||||
|
"{{incident}} | {{details}}",
|
||||||
|
{
|
||||||
|
"incident": flaw.incident,
|
||||||
|
"details": JSON.stringify(flaw.details),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
set_state("done", ["Danke!"]);
|
||||||
}
|
}
|
||||||
set_state("done", "Danke!");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
Loading…
Add table
Reference in a new issue