From f23bd1339c4e4181fe9f57fba6317e6a470c6713 Mon Sep 17 00:00:00 2001 From: Daniel Seifert Date: Mon, 9 Sep 2024 00:05:27 +0200 Subject: [PATCH] get seed from otp saved in session --- Modules/Application/Model/d3_totp_user.php | 15 ++++++++++----- views/twig/admin/d3user_totp.html.twig | 2 +- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/Modules/Application/Model/d3_totp_user.php b/Modules/Application/Model/d3_totp_user.php index 69e8919..23a5fe9 100644 --- a/Modules/Application/Model/d3_totp_user.php +++ b/Modules/Application/Model/d3_totp_user.php @@ -37,21 +37,26 @@ class d3_totp_user extends d3_totp_user_parent /** * @return d3totp */ - public function d3getTotp() + public function d3getTotp(): d3totp { - $totp = oxNew(d3totp::class); - Registry::getSession()->setVariable(d3totp_conf::OTP_SESSION_VARNAME, $totp); - return $totp; + return oxNew(d3totp::class); } /** * @return Session */ - public function d3TotpGetSession() + public function d3TotpGetSession(): Session { return Registry::getSession(); } + public function d3getSessionedTotp(): d3totp + { + $totp = $this->d3getTotp(); + $this->d3TotpGetSession()->setVariable(d3totp_conf::OTP_SESSION_VARNAME, $totp); + return $totp; + } + /** * @return string|null */ diff --git a/views/twig/admin/d3user_totp.html.twig b/views/twig/admin/d3user_totp.html.twig index 9720621..39d8e11 100644 --- a/views/twig/admin/d3user_totp.html.twig +++ b/views/twig/admin/d3user_totp.html.twig @@ -1,7 +1,7 @@ {% include "headitem.html.twig" with {title: "GENERAL_ADMIN_TITLE"|translate} %} {% include "@d3totp/admin/inc/bootstrap.html.twig" %} -{% set totp = edit.d3GetTotp() %} +{% set totp = edit.d3GetSessionedTotp() %} {% set userid = edit.getId() %} {{ totp.loadByUserId(userid) }}