route bugfix, localization
This commit is contained in:
@@ -1259,7 +1259,7 @@ namespace Core\API\User {
|
||||
$settings = $this->context->getSettings();
|
||||
$baseUrl = htmlspecialchars($settings->getBaseUrl());
|
||||
$token = htmlspecialchars(urlencode($token));
|
||||
$url = "$baseUrl/settings?confirmGPG&token=$token"; // TODO: fix this url
|
||||
$url = "$baseUrl/confirmGPG?token=$token";
|
||||
$mailBody = "Hello $name,<br><br>" .
|
||||
"you imported a GPG public key for end-to-end encrypted mail communication. " .
|
||||
"To confirm the key and verify, you own the corresponding private key, please click on the following link. " .
|
||||
|
||||
@@ -8,6 +8,9 @@ return [
|
||||
"accept_invite_description" => "Schließen Sie die Registrierung ab indem Sie ein Passwort wählen",
|
||||
"confirm_email_title" => "E-Mail Adresse bestätigen",
|
||||
"confirm_email_description" => "Schließen Sie die Registrierung ab indem Sie Ihre E-Mail Adresse bestätigen",
|
||||
"confirm_gpg_title" => "GPG-Schlüssel bestätigen",
|
||||
"confirm_gpg_error" => "Fehler beim Bestätigen des GPG-Schlüssels",
|
||||
"confirm_gpg_success" => "GPG-Schlüssel erfolgreich bestätigt",
|
||||
"registration_title" => "Registration",
|
||||
"registration_description" => "Erstelle einen neuen Account",
|
||||
"resend_confirm_email_title" => "Bestätigungsmail erneut senden",
|
||||
@@ -43,7 +46,15 @@ return [
|
||||
"confirm_success" => "Ihre E-Mail Adresse wurde erfolgreich bestätigt, Sie können sich jetzt einloggen",
|
||||
"confirm_error" => "Fehler beim Bestätigen der E-Mail Adresse",
|
||||
"gpg_key" => "GPG-Schlüssel",
|
||||
"no_gpg_key_added" => "Kein GPG-Schlüssel hinzugefügt",
|
||||
"download_gpg_key" => "GPG-Schlüssel herunterladen",
|
||||
"2fa_token" => "Zwei-Faktor Authentifizierung (2FA)",
|
||||
"profile_picture_of" => "Profilbild von",
|
||||
"profile_of" => "Profil von",
|
||||
"language" => "Sprache",
|
||||
"profile" => "Benutzerprofil",
|
||||
"loading_profile" => "Lade Benutzerprofil",
|
||||
"error_profile_get" => "Fehler beim Laden des Benutzerprofils",
|
||||
"registered_at" => "Registriert am",
|
||||
"last_online" => "Zuletzt online",
|
||||
];
|
||||
@@ -6,10 +6,12 @@ return [
|
||||
"retry" => "Erneut versuchen",
|
||||
"go_back" => "Zurück",
|
||||
"save" => "Speichern",
|
||||
"save_only" => "Nur Speichern",
|
||||
"saving" => "Speichere",
|
||||
"unsaved_changes" => "Du hast nicht gespeicherte Änderungen",
|
||||
"new" => "Neu",
|
||||
"edit" => "Bearbeiten",
|
||||
"apply" => "Übernehmen",
|
||||
"submitting" => "Übermittle",
|
||||
"submit" => "Absenden",
|
||||
"request" => "Anfordern",
|
||||
|
||||
@@ -8,6 +8,9 @@ return [
|
||||
"accept_invite_description" => "Complete your account registration by choosing a password",
|
||||
"confirm_email_title" => "Confirm Email",
|
||||
"confirm_email_description" => "Complete your registration by confirming the e-mail address",
|
||||
"confirm_gpg_title" => "Confirm GPG Key",
|
||||
"confirm_gpg_error" => "Error confirming GPG Key",
|
||||
"confirm_gpg_success" => "Successfully confirmed GPG Key",
|
||||
"registration_title" => "Registration",
|
||||
"registration_description" => "Create a new account",
|
||||
"resend_confirm_email_title" => "Resend Confirm Email",
|
||||
@@ -43,7 +46,15 @@ return [
|
||||
"confirm_success" => "Your e-mail address was successfully confirmed, you may now log in",
|
||||
"confirm_error" => "Error confirming e-mail address",
|
||||
"gpg_key" => "GPG Key",
|
||||
"no_gpg_key_added" => "No GPG key added",
|
||||
"download_gpg_key" => "Download GPG Key",
|
||||
"2fa_token" => "Two-Factor Authentication (2FA)",
|
||||
"profile_picture_of" => "Profile Picture of",
|
||||
"profile_of" => "Profile of",
|
||||
"language" => "Language",
|
||||
"profile" => "User Profile",
|
||||
"loading_profile" => "Loading Profile",
|
||||
"error_profile_get" => "Error retrieving user profile",
|
||||
"registered_at" => "Registered At",
|
||||
"last_online" => "Last Online",
|
||||
];
|
||||
@@ -24,6 +24,7 @@ return [
|
||||
"edit" => "Edit",
|
||||
"submitting" => "Submitting",
|
||||
"submit" => "Submit",
|
||||
"apply" => "Apply",
|
||||
"request" => "Request",
|
||||
"cancel" => "Cancel",
|
||||
"confirm" => "Confirm",
|
||||
@@ -36,6 +37,7 @@ return [
|
||||
"retry" => "Retry",
|
||||
"go_back" => "Go Back",
|
||||
"save" => "Save",
|
||||
"save_only" => "Save Only",
|
||||
"saving" => "Saving",
|
||||
"delete" => "Delete",
|
||||
"info" => "Info",
|
||||
|
||||
@@ -105,6 +105,7 @@ class DatabaseEntityQuery extends Select {
|
||||
return $this;
|
||||
}
|
||||
|
||||
// TODO: fix cycle detection + rather use deterministic aliases instead of t1, t2, t3...?
|
||||
private function fetchRelation(string $propertyName, string $tableName, DatabaseEntityHandler $src, DatabaseEntityHandler $relationHandler,
|
||||
bool $recursive = false, string $relationColumnPrefix = "", array &$visited = []) {
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ namespace Core\Objects\DatabaseEntity {
|
||||
}
|
||||
}
|
||||
|
||||
return new Language(1, "en_US", "American English");
|
||||
return self::getPredefinedValues()[0];
|
||||
}
|
||||
|
||||
public function getEntries(?string $module = null): ?array {
|
||||
@@ -101,7 +101,7 @@ namespace Core\Objects\DatabaseEntity {
|
||||
}
|
||||
}
|
||||
|
||||
return "[$key]";
|
||||
return $key ? "[$key]" : "";
|
||||
}
|
||||
|
||||
public function addModule(string $module, array $entries) {
|
||||
@@ -143,8 +143,8 @@ namespace Core\Objects\DatabaseEntity {
|
||||
|
||||
public static function getPredefinedValues(): array {
|
||||
return [
|
||||
new Language(Language::AMERICAN_ENGLISH, "en_US", 'American English'),
|
||||
new Language(Language::GERMAN_STANDARD, "de_DE", 'Deutsch Standard'),
|
||||
new Language(Language::AMERICAN_ENGLISH, "en_US", 'English (US)'),
|
||||
new Language(Language::GERMAN_STANDARD, "de_DE", 'Deutsch (Standard)'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -153,7 +153,7 @@ namespace Core\Objects\DatabaseEntity {
|
||||
namespace {
|
||||
function L(string $key): string {
|
||||
if (!array_key_exists('LANGUAGE', $GLOBALS)) {
|
||||
return "[$key]";
|
||||
return $key ? "[$key]" : "";
|
||||
}
|
||||
|
||||
global $LANGUAGE;
|
||||
|
||||
@@ -107,15 +107,23 @@ abstract class Route extends DatabaseEntity {
|
||||
return "new $className($args)";
|
||||
}
|
||||
|
||||
private static function getParts(string $url): array {
|
||||
if ($url === "/" || $url === "") {
|
||||
return [];
|
||||
} else {
|
||||
return explode("/", $url);
|
||||
}
|
||||
}
|
||||
|
||||
public function match(string $url) {
|
||||
|
||||
# /test/{abc}/{param:?}/{xyz:int}/{aaa:int?}
|
||||
$patternParts = explode("/", Router::cleanURL($this->pattern, false));
|
||||
$patternParts = self::getParts(Router::cleanURL($this->pattern, false));
|
||||
$countPattern = count($patternParts);
|
||||
$patternOffset = 0;
|
||||
|
||||
# /test/param/optional/123
|
||||
$urlParts = explode("/", Router::cleanURL($url));
|
||||
$urlParts = self::getParts(Router::cleanURL($url));
|
||||
$countUrl = count($urlParts);
|
||||
$urlOffset = 0;
|
||||
|
||||
@@ -235,6 +243,7 @@ abstract class Route extends DatabaseEntity {
|
||||
new DocumentRoute("/admin", false, \Core\Documents\Admin::class),
|
||||
new DocumentRoute("/register", true, \Core\Documents\Account::class, "account/register.twig"),
|
||||
new DocumentRoute("/confirmEmail", true, \Core\Documents\Account::class, "account/confirm_email.twig"),
|
||||
new DocumentRoute("/confirmGPG", true, \Core\Documents\Account::class, "account/confirm_gpg.twig"),
|
||||
new DocumentRoute("/acceptInvite", true, \Core\Documents\Account::class, "account/accept_invite.twig"),
|
||||
new DocumentRoute("/resetPassword", true, \Core\Documents\Account::class, "account/reset_password.twig"),
|
||||
new DocumentRoute("/login", true, \Core\Documents\Account::class, "account/login.twig"),
|
||||
|
||||
36
Core/Templates/account/confirm_gpg.twig
Normal file
36
Core/Templates/account/confirm_gpg.twig
Normal file
@@ -0,0 +1,36 @@
|
||||
{% extends "account/account_base.twig" %}
|
||||
|
||||
{% set view_title = 'account.confirm_gpg_title' %}
|
||||
{% set view_icon = 'user-check' %}
|
||||
{% set view_description = '' %}
|
||||
|
||||
{% block view_content %}
|
||||
<noscript>
|
||||
<div class="alert alert-danger">{{ L('general.noscript') }}</div>
|
||||
</noscript>
|
||||
<div class="alert alert-info" id="confirm-status">
|
||||
{{ L('account.confirming_gpg') }}… <i class="fas fa-spinner fa-spin"></i>
|
||||
</div>
|
||||
<script nonce="{{ site.csp.nonce }}">
|
||||
$(document).ready(function() {
|
||||
let token = jsCore.getParameter("token");
|
||||
let confirmStatus = $("#confirm-status");
|
||||
if (token) {
|
||||
jsCore.apiCall("/user/confirmGPG", { token: token, csrfToken: '{{ user.session.csrfToken }}' }, (res) => {
|
||||
confirmStatus.removeClass("alert-info");
|
||||
if (!res.success) {
|
||||
confirmStatus.addClass("alert-danger");
|
||||
confirmStatus.text("{{ L('account.confirm_gpg_error') }}: " + res.msg);
|
||||
} else {
|
||||
confirmStatus.addClass("alert-success");
|
||||
confirmStatus.text("{{ L('account.confirm_gpg_success') }}");
|
||||
}
|
||||
});
|
||||
} else {
|
||||
confirmStatus.removeClass("alert-info");
|
||||
confirmStatus.addClass("alert-danger");
|
||||
confirmStatus.text("{{ L('account.invalid_link') }}");
|
||||
}
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user