From e4c2212070462e15637c2f4d7f2087c6d4d54813 Mon Sep 17 00:00:00 2001 From: aB0t Date: Fri, 28 Jul 2023 08:15:37 +0200 Subject: [PATCH] update 2023-07-28 08:15:37 --- .../README.md | 18 +++++++--- .../code.php | 35 +++++++++++++++++++ .../code.power | 35 +++++++++++++++++++ 3 files changed, 83 insertions(+), 5 deletions(-) diff --git a/src/36ab759f-7b42-4465-9c17-56ba1dd05f90/README.md b/src/36ab759f-7b42-4465-9c17-56ba1dd05f90/README.md index 55c5853..4850c44 100644 --- a/src/36ab759f-7b42-4465-9c17-56ba1dd05f90/README.md +++ b/src/36ab759f-7b42-4465-9c17-56ba1dd05f90/README.md @@ -26,6 +26,7 @@ class Linker << (F,LightGreen) >> #Green { + set(string $linker) : bool + setName(string $name) : ?array + access(string $linker, string $pass, ...) : ?array + + revoke(string $linker) : ?array - hasAccess(string $linker, string $pass) : bool - getPassGuid(string $linker, string $pass) : ?string - getPassword(string $linker, string $pass) : ?object @@ -113,35 +114,42 @@ note left of Linker::access ?string $oldPass end note -note right of Linker::hasAccess +note right of Linker::revoke + Revoke Access + + since: 2.0.1 + return: ?array +end note + +note left of Linker::hasAccess Has Access since: 2.0.1 return: bool end note -note left of Linker::getPassGuid +note right of Linker::getPassGuid Get Password GUID since: 2.0.1 return: ?string end note -note right of Linker::getPassword +note left of Linker::getPassword Get Password since: 2.0.1 return: ?object end note -note left of Linker::setLinker +note right of Linker::setLinker Set Linker since: 2.0.1 return: bool end note -note right of Linker::setPassword +note left of Linker::setPassword Set Password since: 2.0.1 diff --git a/src/36ab759f-7b42-4465-9c17-56ba1dd05f90/code.php b/src/36ab759f-7b42-4465-9c17-56ba1dd05f90/code.php index 7a1c786..2e577e7 100644 --- a/src/36ab759f-7b42-4465-9c17-56ba1dd05f90/code.php +++ b/src/36ab759f-7b42-4465-9c17-56ba1dd05f90/code.php @@ -369,6 +369,41 @@ final class Linker return (array) $_linker; } + /** + * Revoke Access + * + * @param string $linker The linker GUID value + * + * @return array|null The success or error details + * @since 2.0.1 + **/ + public function revoke(string $linker): ?array + { + // linker not valid GUID + if (!GuidHelper::valid($linker)) + { + // hmm we can log this + return [ + 'success' => Text::_('COM_GETBIBLE_ACCESS_REVOKED') + ]; + } + + if (($access = $this->session->get("getbible_active_{$linker}", null)) === null + || $access !== 'valid_access') + { + // hmm we can log this + return [ + 'success' => Text::_('COM_GETBIBLE_ACCESS_REVOKED') + ]; + } + + $this->session->set("getbible_active_{$linker}", null); + + return [ + 'success' => Text::_('COM_GETBIBLE_ACCESS_REVOKED') + ]; + } + /** * Has Access * diff --git a/src/36ab759f-7b42-4465-9c17-56ba1dd05f90/code.power b/src/36ab759f-7b42-4465-9c17-56ba1dd05f90/code.power index 394a2cf..7fbc1ce 100644 --- a/src/36ab759f-7b42-4465-9c17-56ba1dd05f90/code.power +++ b/src/36ab759f-7b42-4465-9c17-56ba1dd05f90/code.power @@ -339,6 +339,41 @@ return (array) $_linker; } + /** + * Revoke Access + * + * @param string $linker The linker GUID value + * + * @return array|null The success or error details + * @since 2.0.1 + **/ + public function revoke(string $linker): ?array + { + // linker not valid GUID + if (!GuidHelper::valid($linker)) + { + // hmm we can log this + return [ + 'success' => Text::_('Access revoked.') + ]; + } + + if (($access = $this->session->get("getbible_active_{$linker}", null)) === null + || $access !== 'valid_access') + { + // hmm we can log this + return [ + 'success' => Text::_('Access revoked.') + ]; + } + + $this->session->set("getbible_active_{$linker}", null); + + return [ + 'success' => Text::_('Access revoked.') + ]; + } + /** * Has Access *