Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions application/exceptions/ForgotPasswordApplicationException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php

class ForgotPasswordApplicationException extends Exception
{
}
5 changes: 5 additions & 0 deletions application/exceptions/ForgotPasswordUserInputException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php

class ForgotPasswordUserInputException extends Exception
{
}
22 changes: 12 additions & 10 deletions application/loginwebpage.class.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,15 +221,15 @@ protected function ForgotPwdGo()

if ($oUser != null) {
if (!MetaModel::IsValidAttCode(get_class($oUser), 'reset_pwd_token')) {
throw new Exception(Dict::S('UI:ResetPwd-Error-NotPossible'));
throw new ForgotPasswordUserInputException(Dict::S('UI:ResetPwd-Error-NotPossible'));
}
if (!$oUser->CanChangePassword()) {
throw new Exception(Dict::S('UI:ResetPwd-Error-FixedPwd'));
throw new ForgotPasswordUserInputException(Dict::S('UI:ResetPwd-Error-FixedPwd'));
}

$sTo = $oUser->GetResetPasswordEmail(); // throws Exceptions if not allowed
if ($sTo == '') {
throw new Exception(Dict::S('UI:ResetPwd-Error-NoEmail'));
throw new ForgotPasswordUserInputException(Dict::S('UI:ResetPwd-Error-NoEmail'));
}

// This token allows the user to change the password without knowing the previous one
Expand All @@ -255,17 +255,19 @@ protected function ForgotPwdGo()

case EMAIL_SEND_ERROR:
default:
IssueLog::Error('Failed to send the email with the NEW password for '.$oUser->Get('friendlyname').': '.implode(', ', $aIssues));
throw new Exception(Dict::S('UI:ResetPwd-Error-Send'));
throw new ForgotPasswordApplicationException('Failed to send the email with the NEW password for ' . $oUser->Get('friendlyname') . ': ' . implode(', ', $aIssues));
}
}

$oTwigContext = new LoginTwigRenderer();
$aVars = $oTwigContext->GetDefaultVars();
$oTwigContext->Render($this, 'forgotpwdsent.html.twig', $aVars);
} catch (Exception $e) {
$this->DisplayForgotPwdForm(true, $e->getMessage());
} catch (ForgotPasswordApplicationException $e) {
IssueLog::Error('Failed to process the forgot password request for user "' . $sAuthUser . '": ' . $e->getMessage());
} catch (ForgotPasswordUserInputException $e) {
IssueLog::Info('Failed to process the forgot password request for user "' . $sAuthUser . '": ' . $e->getMessage());
}

$oTwigContext = new LoginTwigRenderer();
$aVars = $oTwigContext->GetDefaultVars();
$oTwigContext->Render($this, 'forgotpwdsent.html.twig', $aVars);
}

public function DisplayResetPwdForm($sErrorMessage = null)
Expand Down
2 changes: 2 additions & 0 deletions lib/composer/autoload_classmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -745,6 +745,8 @@
'Firebase\\JWT\\JWTExceptionWithPayloadInterface' => $vendorDir . '/firebase/php-jwt/src/JWTExceptionWithPayloadInterface.php',
'Firebase\\JWT\\Key' => $vendorDir . '/firebase/php-jwt/src/Key.php',
'Firebase\\JWT\\SignatureInvalidException' => $vendorDir . '/firebase/php-jwt/src/SignatureInvalidException.php',
'ForgotPasswordApplicationException' => $baseDir . '/application/exceptions/ForgotPasswordApplicationException.php',
'ForgotPasswordUserInputException' => $baseDir . '/application/exceptions/ForgotPasswordUserInputException.php',
'FunctionExpression' => $baseDir . '/core/oql/expression.class.inc.php',
'FunctionOqlExpression' => $baseDir . '/core/oql/oqlquery.class.inc.php',
'GraphEdge' => $baseDir . '/core/simplegraph.class.inc.php',
Expand Down
Loading