From 454bbb8e64a20a5c3624643e10365f24b58cac55 Mon Sep 17 00:00:00 2001 From: Jan Kristinus Date: Fri, 15 Nov 2024 15:59:31 +0100 Subject: [PATCH] Tableset, Pages mit Yform5 --- boot.php | 20 +- install/tablesets/yform_user.json | 589 ++++++++++++++++-------------- lib/ycom_user.php | 3 +- plugins/auth/lang/de_de.lang | 5 + 4 files changed, 338 insertions(+), 279 deletions(-) diff --git a/boot.php b/boot.php index 9b9996f..ec2b040 100644 --- a/boot.php +++ b/boot.php @@ -5,22 +5,30 @@ * @psalm-scope-this rex_addon */ -// include __DIR__.'/vendor/guzzlehttp/promises/src/functions_include.php'; -// include __DIR__.'/vendor/guzzlehttp/guzzle/src/functions_include.php'; -// - rex_ycom_auth::addInjection(new rex_ycom_injection_otp(), 1); rex_ycom_auth::addInjection(new rex_ycom_injection_passwordchange(), 4); rex_ycom_auth::addInjection(new rex_ycom_injection_termsofuse(), 8); if (rex::isBackend()) { rex_extension::register('PACKAGES_INCLUDED', static function ($params) { + $addon = rex_addon::get('yform'); $plugin = rex_plugin::get('yform', 'manager'); - if ($plugin->isAvailable()) { + // YForm <= 5 $pages = $plugin->getProperty('pages'); $ycom_tables = rex_ycom::getTables(); - + if (isset($pages) && is_array($pages)) { + foreach ($pages as $page) { + if (in_array($page->getKey(), $ycom_tables, true)) { + $page->setBlock('ycom'); + // $page->setRequiredPermissions('ycom[]'); + } + } + } + } else { + // YForm >= 5 + $pages = $addon->getProperty('pages'); + $ycom_tables = rex_ycom::getTables(); if (isset($pages) && is_array($pages)) { foreach ($pages as $page) { if (in_array($page->getKey(), $ycom_tables, true)) { diff --git a/install/tablesets/yform_user.json b/install/tablesets/yform_user.json index 3434a91..af0f357 100644 --- a/install/tablesets/yform_user.json +++ b/install/tablesets/yform_user.json @@ -1,466 +1,511 @@ { "rex_ycom_user": { - "table": { - "status": 1, - "table_name": "rex_ycom_user", - "name": "translate:rex_ycom_user", - "description": "", - "list_amount": 100, - "list_sortfield": "login", - "list_sortorder": "DESC", - "search": 1, - "hidden": 0, - "export": 1, - "import": 1, - "mass_deletion": 0, - "mass_edit": 0, - "schema_overwrite": 1, - "history": 0, - "exclusive_view_roles": "", - "exclusive_edit_roles": "" - }, "fields": [ { - "table_name": "rex_ycom_user", - "prio": 1, - "type_id": "value", - "type_name": "html", "db_type": "", + "html": "
", + "label": "html1", "list_hidden": 0, - "search": 0, "name": "html1", - "label": "html1", "not_required": "", - "html": "
" - }, - { + "prio": 1, + "search": 0, "table_name": "rex_ycom_user", - "prio": 2, "type_id": "value", - "type_name": "text", + "type_name": "html" + }, + { + "append": "", + "attributes": "", "db_type": "", + "default": "", + "label": "translate:login", "list_hidden": 1, - "search": 1, "name": "login", - "label": "translate:login", - "not_required": "", - "default": "", "no_db": "", + "not_required": "", "notice": "", - "attributes": "", "prepend": "", - "append": "" + "prio": 2, + "search": 1, + "table_name": "rex_ycom_user", + "type_id": "value", + "type_name": "text" }, { - "table_name": "rex_ycom_user", - "prio": 3, - "type_id": "validate", - "type_name": "empty", "db_type": "", + "label": "", "list_hidden": 1, - "search": 0, + "message": "translate:ycom_please_enter_login", "name": "login", - "label": "", "not_required": "", - "message": "translate:ycom_please_enter_login" - }, - { + "prio": 3, + "search": 0, "table_name": "rex_ycom_user", - "prio": 4, "type_id": "validate", - "type_name": "unique", + "type_name": "empty" + }, + { "db_type": "", + "empty_option": "", + "label": "", "list_hidden": 1, - "search": 0, + "message": "translate:ycom_this_login_exists_already", "name": "login", - "label": "", "not_required": "", - "message": "translate:ycom_this_login_exists_already", + "prio": 4, + "search": 0, "table": "rex_ycom_user", - "empty_option": "" + "table_name": "rex_ycom_user", + "type_id": "validate", + "type_name": "unique" }, { - "table_name": "rex_ycom_user", - "prio": 5, - "type_id": "value", - "type_name": "text", + "append": "", + "attributes": "", "db_type": "", + "default": "", + "label": "translate:email", "list_hidden": 0, - "search": 1, "name": "email", - "label": "translate:email", - "not_required": "", - "default": "", "no_db": "", + "not_required": "", "notice": "", - "attributes": "", "prepend": "", - "append": "" + "prio": 5, + "search": 1, + "table_name": "rex_ycom_user", + "type_id": "value", + "type_name": "text" }, { - "table_name": "rex_ycom_user", - "prio": 6, - "type_id": "validate", - "type_name": "empty", "db_type": "", + "label": "", "list_hidden": 1, - "search": 0, + "message": "translate:ycom_please_enter_email", "name": "email", - "label": "", "not_required": "", - "message": "translate:ycom_please_enter_email" - }, - { + "prio": 6, + "search": 0, "table_name": "rex_ycom_user", - "prio": 7, "type_id": "validate", - "type_name": "type", + "type_name": "empty" + }, + { "db_type": "", + "label": "", "list_hidden": 1, - "search": 0, + "message": "translate:ycom_please_enter_email", "name": "email", - "label": "", "not_required": "", - "message": "translate:ycom_please_enter_email", - "type": "email" - }, - { + "prio": 7, + "search": 0, "table_name": "rex_ycom_user", - "prio": 8, + "type": "email", "type_id": "validate", - "type_name": "unique", + "type_name": "type" + }, + { "db_type": "", + "empty_option": "", + "label": "", "list_hidden": 1, - "search": 0, + "message": "translate:ycom_this_email_exists_already", "name": "email", - "label": "", "not_required": "", - "message": "translate:ycom_this_email_exists_already", + "prio": 8, + "search": 0, "table": "rex_ycom_user", - "empty_option": "" + "table_name": "rex_ycom_user", + "type_id": "validate", + "type_name": "unique" }, { - "table_name": "rex_ycom_user", - "prio": 9, - "type_id": "value", - "type_name": "ycom_auth_password", + "attributes": "", "db_type": "", + "label": "translate:password", "list_hidden": 1, - "search": 1, + "message": "translate:ycom_validate_password_policy_rules_error", "name": "password", - "label": "translate:password", "not_required": "", - "message": "translate:ycom_validate_password_policy_rules_error", - "attributes": "", + "prio": 9, "rules": "{\"length\":{\"min\":8},\"letter\":{\"min\":1},\"lowercase\":{\"min\":1},\"uppercase\":{\"min\":1}}", - "script": "1" - }, - { + "script": "1", + "search": 1, "table_name": "rex_ycom_user", - "prio": 10, "type_id": "value", - "type_name": "text", + "type_name": "ycom_auth_password" + }, + { + "append": "", + "attributes": "", "db_type": "", + "default": "", + "label": "translate:firstname", "list_hidden": 0, - "search": 1, "name": "firstname", - "label": "translate:firstname", - "not_required": "", - "default": "", "no_db": "", + "not_required": "", "notice": "", - "attributes": "", "prepend": "", - "append": "" - }, - { + "prio": 10, + "search": 1, "table_name": "rex_ycom_user", - "prio": 11, "type_id": "value", - "type_name": "text", + "type_name": "text" + }, + { + "append": "", + "attributes": "", "db_type": "", + "default": "", + "label": "translate:name", "list_hidden": 0, - "search": 1, "name": "name", - "label": "translate:name", - "not_required": "", - "default": "", "no_db": "", + "not_required": "", "notice": "", - "attributes": "", "prepend": "", - "append": "" - }, - { + "prio": 11, + "search": 1, "table_name": "rex_ycom_user", - "prio": 12, "type_id": "value", - "type_name": "html", + "type_name": "text" + }, + { "db_type": "", + "html": "<\/div>
", + "label": "html2", "list_hidden": 0, - "search": 0, "name": "html2", - "label": "html2", "not_required": "", - "html": "<\/div>
" - }, - { + "prio": 12, + "search": 0, "table_name": "rex_ycom_user", - "prio": 13, "type_id": "value", - "type_name": "choice", + "type_name": "html" + }, + { + "attributes": "", + "choice_attributes": "", + "choice_label": "", + "choices": "translate:ycom_account_inactive_termination=-3,translate:ycom_account_inactive_logins=-2,translate:ycom_account_inactive=-1,translate:ycom_account_requested=0,translate:ycom_account_confirm=1,translate:ycom_account_active=2", "db_type": "", - "list_hidden": 0, - "search": 1, - "name": "status", + "default": "-1", + "expanded": "", + "group_attributes": "", + "group_by": "", "label": "translate:status", - "not_required": "", + "list_hidden": 0, "multiple": "0", - "expanded": "", - "choices": "translate:ycom_account_inactive_termination=-3,translate:ycom_account_inactive_logins=-2,translate:ycom_account_inactive=-1,translate:ycom_account_requested=0,translate:ycom_account_confirm=1,translate:ycom_account_active=2", - "choice_attributes": "", - "default": "-1", + "name": "status", "no_db": "", + "not_required": "", "notice": "", - "attributes": "", "placeholder": "", - "group_by": "", - "group_attributes": "", - "preferred_choices": "" + "preferred_choices": "", + "prio": 13, + "search": 1, + "table_name": "rex_ycom_user", + "type_id": "value", + "type_name": "choice" }, { - "table_name": "rex_ycom_user", + "attributes": "", + "db_type": "text", + "empty_option": "1", + "empty_value": "", + "field": "name", + "filter": "", + "label": "translate:ycom_groups", + "list_hidden": 1, + "name": "ycom_groups", + "not_required": "", + "notice": "", "prio": 14, + "relation_table": "", + "search": 1, + "size": "", + "table": "rex_ycom_group", + "table_name": "rex_ycom_user", + "type": "1", "type_id": "value", - "type_name": "generate_key", + "type_name": "be_manager_relation" + }, + { "db_type": "", + "label": "translate:activation_key", "list_hidden": 1, - "search": 1, "name": "activation_key", - "label": "translate:activation_key", + "no_db": "", "not_required": "", "only_empty": "1", - "no_db": "", - "show_value": "1" + "prio": 15, + "search": 1, + "show_value": "1", + "table_name": "rex_ycom_user", + "type_id": "value", + "type_name": "generate_key" }, { - "table_name": "rex_ycom_user", - "prio": 15, - "type_id": "validate", - "type_name": "unique", "db_type": "", + "empty_option": "0", + "label": "", "list_hidden": 1, - "search": 0, + "message": "translate:ycom_this_activation_key_exists_already", "name": "activation_key", - "label": "", "not_required": "", - "message": "translate:ycom_this_activation_key_exists_already", + "prio": 16, + "search": 0, "table": "rex_ycom_user", - "empty_option": "0" + "table_name": "rex_ycom_user", + "type_id": "validate", + "type_name": "unique" }, { - "table_name": "rex_ycom_user", - "prio": 17, - "type_id": "value", - "type_name": "checkbox", + "attributes": "", "db_type": "tinyint(1)", + "default": "0", + "label": "translate:termsofuse_accepted", "list_hidden": 1, - "search": 1, "name": "termsofuse_accepted", - "label": "translate:termsofuse_accepted", - "not_required": "", - "default": "0", "no_db": "0", + "not_required": "", "notice": "", - "attributes": "", - "output_values": "" - }, - { + "output_values": "", + "prio": 17, + "search": 1, "table_name": "rex_ycom_user", - "prio": 18, "type_id": "value", - "type_name": "checkbox", + "type_name": "checkbox" + }, + { + "attributes": "", "db_type": "tinyint(1)", + "default": "0", + "label": "translate:new_password_required", "list_hidden": 1, - "search": 1, "name": "new_password_required", - "label": "translate:new_password_required", - "not_required": "", - "default": "0", "no_db": "0", + "not_required": "", "notice": "", - "attributes": "", - "output_values": "" - }, - { + "output_values": "", + "prio": 18, + "search": 1, "table_name": "rex_ycom_user", - "prio": 19, "type_id": "value", - "type_name": "datestamp", + "type_name": "checkbox" + }, + { "db_type": "", + "format": "", + "label": "translate:last_action_time", "list_hidden": 1, - "search": 1, + "modify_default": "", "name": "last_action_time", - "label": "translate:last_action_time", + "no_db": "", "not_required": "", "only_empty": "2", - "no_db": "", - "format": "", - "modify_default": "" - }, - { + "prio": 19, + "search": 1, "table_name": "rex_ycom_user", - "prio": 20, "type_id": "value", - "type_name": "datestamp", + "type_name": "datestamp" + }, + { "db_type": "", + "format": "", + "label": "translate:last_login_time", "list_hidden": 1, - "search": 1, + "modify_default": "", "name": "last_login_time", - "label": "translate:last_login_time", + "no_db": "", "not_required": "", "only_empty": "2", - "no_db": "", - "format": "", - "modify_default": "" - }, - { + "prio": 20, + "search": 1, "table_name": "rex_ycom_user", - "prio": 21, "type_id": "value", - "type_name": "datestamp", + "type_name": "datestamp" + }, + { "db_type": "", + "format": "", + "label": "translate:last_login_try_time", "list_hidden": 1, - "search": 1, + "modify_default": "", "name": "last_login_try_time", - "label": "translate:last_login_try_time", + "no_db": "", "not_required": "", "only_empty": "2", - "no_db": "", - "format": "", - "modify_default": "" - }, - { + "prio": 21, + "search": 1, "table_name": "rex_ycom_user", - "prio": 22, "type_id": "value", - "type_name": "datestamp", + "type_name": "datestamp" + }, + { "db_type": "", + "format": "", + "label": "translate:termination_time", "list_hidden": 1, - "search": 1, + "modify_default": "", "name": "termination_time", - "label": "translate:termination_time", + "no_db": "", "not_required": "", "only_empty": "2", - "no_db": "", - "format": "", - "modify_default": "" - }, - { + "prio": 22, + "search": 1, "table_name": "rex_ycom_user", - "prio": 23, "type_id": "value", - "type_name": "integer", + "type_name": "datestamp" + }, + { "db_type": "", + "default": "0", + "label": "translate:login_tries", "list_hidden": 0, - "search": 1, "name": "login_tries", - "label": "translate:login_tries", - "not_required": "", - "default": "0", "no_db": "", + "not_required": "", "notice": "translate:ycom_login_tries_info", + "prio": 23, + "search": 1, + "table_name": "rex_ycom_user", + "type_id": "value", + "type_name": "integer", "unit": "" }, { - "table_name": "rex_ycom_user", + "db_type": "int", + "default": "0", + "label": "translate:otp_tries", + "list_hidden": 1, + "name": "otp_tries", + "no_db": "0", + "not_required": "", + "notice": "translate:otp_tries_info", "prio": 24, + "search": 1, + "table_name": "rex_ycom_user", "type_id": "value", - "type_name": "html", - "db_type": "", - "list_hidden": 0, - "search": 0, - "name": "html3", - "label": "html3", + "type_name": "integer", + "unit": "" + }, + { + "db_type": "text", + "label": "translate:otp_last_try_time", + "list_hidden": 1, + "name": "otp_last_try_time", "not_required": "", - "html": "<\/div><\/div>" + "prio": 25, + "search": 0, + "show_value": "0", + "table_name": "rex_ycom_user", + "type_id": "value", + "type_name": "emptyname" }, { + "db_type": "text", + "label": "translate:otp_config", + "list_hidden": 1, + "name": "otp_config", + "not_required": "", + "prio": 26, + "search": 0, + "show_value": "0", "table_name": "rex_ycom_user", - "prio": 25, "type_id": "value", - "type_name": "be_manager_relation", + "type_name": "emptyname" + }, + { "db_type": "", - "list_hidden": 1, - "search": 1, - "name": "ycom_groups", - "label": "translate:ycom_groups", + "html": "<\/div><\/div>", + "label": "html3", + "list_hidden": 0, + "name": "html3", "not_required": "", - "size": "", - "table": "rex_ycom_group", - "field": "name", - "type": "1", - "empty_value": "", - "empty_option": "1", - "notice": "", - "attributes": "", - "relation_table": "", - "filter": "" + "prio": 27, + "search": 0, + "table_name": "rex_ycom_user", + "type_id": "value", + "type_name": "html" } - ] - }, - "rex_ycom_group": { + ], "table": { - "status": 1, - "table_name": "rex_ycom_group", - "name": "translate:ycom_group_name", "description": "", - "list_amount": 200, - "list_sortfield": "name", - "list_sortorder": "ASC", - "search": 0, - "hidden": 0, + "exclusive_edit_roles": "", + "exclusive_view_roles": "", "export": 1, + "hidden": 0, + "history": 0, "import": 1, + "list_amount": 100, + "list_sortfield": "login", + "list_sortorder": "DESC", "mass_deletion": 0, "mass_edit": 0, + "name": "translate:rex_ycom_user", "schema_overwrite": 1, - "history": 0, - "exclusive_view_roles": "", - "exclusive_edit_roles": "" - }, + "search": 1, + "status": 1, + "table_icon": "", + "table_name": "rex_ycom_user" + } + }, + "rex_ycom_group": { "fields": [ { - "table_name": "rex_ycom_group", - "prio": 1, - "type_id": "value", - "type_name": "text", + "append": "", + "attributes": "", "db_type": "", + "default": "", + "label": "translate:name", "list_hidden": 0, - "search": 1, "name": "name", - "label": "translate:name", - "not_required": "", - "default": "", "no_db": "", + "not_required": "", "notice": "", - "attributes": "", "prepend": "", - "append": "" + "prio": 1, + "search": 1, + "table_name": "rex_ycom_group", + "type_id": "value", + "type_name": "text" }, { - "table_name": "rex_ycom_group", - "prio": 2, - "type_id": "validate", - "type_name": "empty", "db_type": "", + "label": "", "list_hidden": 1, - "search": 0, + "message": "translate:ycom_group_yform_enter_name", "name": "name", - "label": "", "not_required": "", - "message": "translate:ycom_group_yform_enter_name" + "prio": 2, + "search": 0, + "table_name": "rex_ycom_group", + "type_id": "validate", + "type_name": "empty" } - ] + ], + "table": { + "description": "", + "exclusive_edit_roles": "", + "exclusive_view_roles": "", + "export": 1, + "hidden": 0, + "history": 0, + "import": 1, + "list_amount": 200, + "list_sortfield": "name", + "list_sortorder": "ASC", + "mass_deletion": 0, + "mass_edit": 0, + "name": "translate:ycom_group_name", + "schema_overwrite": 1, + "search": 0, + "status": 1, + "table_icon": "", + "table_name": "rex_ycom_group" + } } -} +} \ No newline at end of file diff --git a/lib/ycom_user.php b/lib/ycom_user.php index 00300a5..ae2100c 100644 --- a/lib/ycom_user.php +++ b/lib/ycom_user.php @@ -99,7 +99,8 @@ public function increaseLoginTries(): self public function increaseOTPTries(): self { - $this->setValue('otp_tries', $this->getValue('otp_tries') + 1); + $otp_tries = (int) $this->getValue('otp_tries'); + $this->setValue('otp_tries', $otp_tries + 1); $this->setValue('otp_last_try_time', time()); return $this; } diff --git a/plugins/auth/lang/de_de.lang b/plugins/auth/lang/de_de.lang index 6f04a37..2b25d09 100644 --- a/plugins/auth/lang/de_de.lang +++ b/plugins/auth/lang/de_de.lang @@ -93,3 +93,8 @@ otp_auth_totp_period = Zeitintervall bei Authentikatoren (nicht veränderbar) otp_auth_totp_period_info = {0} Sekunden otp_auth_logintries = Anzahl der erlaubten Fehlversuche (nicht veränderbar) otp_auth_logintries_info = {0} Versuche + +otp_tries = OTP Fehlversuche +otp_tries_info = Erlaubte Fehlversuche werden im Plugin YCom/Auth definiert +otp_last_try_time = OTP Letzter Versuch +otp_config = OTP Config