From a660541540ee473c2cada9b903493856b438f713 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Suwi=C5=84ski?= Date: Wed, 18 Nov 2020 19:38:58 +0100 Subject: [PATCH] gen_otp refactoring --- auth.php | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/auth.php b/auth.php index 656df4b..510d3cf 100644 --- a/auth.php +++ b/auth.php @@ -205,21 +205,17 @@ class auth_plugin_emailotp extends auth_plugin_base { 'password' => password_hash($newpassword, PASSWORD_DEFAULT), 'login_failed_count' => 0, ); - $a = (object)array( + $user = (object)array( + 'id' => -1, // Fake due email_to_user() requirements. + 'auth' => $this->authtype, 'username' => $username, + 'email' => $username, 'password' => $newpassword, ); - return email_to_user( - (object)array( - 'id' => -1, - 'auth' => $this->authtype, - 'username ' => $username, - 'email' => $username, - ), - core_user::get_support_user(), - sprintf('%s: %s', format_string(get_site()->fullname), - get_string('otpgeneratedsubj', self::COMPONENT_NAME, $a)), - get_string('otpgeneratedtext', self::COMPONENT_NAME, $a) + return email_to_user($user, core_user::get_support_user(), + format_string(get_site()->fullname).': '. + get_string('otpgeneratedsubj', self::COMPONENT_NAME, $user), + get_string('otpgeneratedtext', self::COMPONENT_NAME, $user) ); }