diff --git a/application/loginwebpage.class.inc.php b/application/loginwebpage.class.inc.php index 751124bd5..b1fef599c 100644 --- a/application/loginwebpage.class.inc.php +++ b/application/loginwebpage.class.inc.php @@ -245,7 +245,7 @@ class LoginWebPage extends NiceWebPage } } - public function DisplayResetPwdForm() + public function DisplayResetPwdForm($sErrorMessage = null) { $sAuthUser = utils::ReadParam('auth_user', '', false, 'raw_data'); $sToken = utils::ReadParam('token', '', false, 'raw_data'); @@ -258,6 +258,8 @@ class LoginWebPage extends NiceWebPage $aVars['sAuthUser'] = $sAuthUser; $aVars['sToken'] = $sToken; + $aVars['sErrorMessage'] = $sErrorMessage; + if (($oUser == null)) { $aVars['bNoUser'] = true; @@ -288,6 +290,7 @@ class LoginWebPage extends NiceWebPage $sNewPwd = utils::ReadPostedParam('new_pwd', '', 'raw_data'); UserRights::Login($sAuthUser); // Set the user's language + /** @var \UserLocal $oUser */ $oUser = UserRights::GetUserObject(); $oTwigContext = new LoginTwigRenderer(); @@ -1032,8 +1035,17 @@ class LoginWebPage extends NiceWebPage } else if ($operation == 'do_reset_pwd') { - $oPage = self::NewLoginWebPage(); - $oPage->DoResetPassword(); + + try { + $oPage = self::NewLoginWebPage(); + $oPage->DoResetPassword(); + } + catch (CoreCannotSaveObjectException $e) + { + $oPage = self::NewLoginWebPage(); + $oPage->DisplayResetPwdForm($e->getIssue()); + } + $oPage->output(); exit; } diff --git a/core/userrights.class.inc.php b/core/userrights.class.inc.php index 0aceccc47..309565a43 100644 --- a/core/userrights.class.inc.php +++ b/core/userrights.class.inc.php @@ -837,6 +837,7 @@ class UserRights } } + /** User */ public static function GetUserObject() { if (is_null(self::$m_oUser)) diff --git a/templates/login/password/resetpwdform.html.twig b/templates/login/password/resetpwdform.html.twig index b63ec0ef3..bf18e24c6 100644 --- a/templates/login/password/resetpwdform.html.twig +++ b/templates/login/password/resetpwdform.html.twig @@ -7,36 +7,39 @@

{{ 'UI:ResetPwd-Title'|dict_s }}

- {% if bNoUser %} + {% if bNoUser and sErrorMessage is null %}

{{ 'UI:ResetPwd-Error-WrongLogin'|dict_format(sAuthUser) }}

- {% elseif bBadToken %} + {% elseif bBadToken and sErrorMessage is null %}

{{ 'UI:ResetPwd-Error-InvalidToken'|dict_s }}

{% else %} -

{{ 'UI:ResetPwd-Error-EnterPassword'|dict_format(sUserName) }}

-
-
-
-
-
-
- - + {% if sErrorMessage is not null %} +

{{ sErrorMessage|raw }}

+ {% endif %} +

{{ 'UI:ResetPwd-Error-EnterPassword'|dict_format(sUserName) }}

+
+
+ +
+
+
+ + +
+
+ + +
-
- - +
+
+ +
-
-
-
- -
-
-
- - - - +
+ + + + {% endif %}