Skip to content

Commit b8d7102

Browse files
committed
N°8545 - Change log severity depending on the error source
1 parent c62a78b commit b8d7102

File tree

5 files changed

+92
-77
lines changed

5 files changed

+92
-77
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?php
2+
3+
class ForgotPasswordApplicationException extends Exception
4+
{
5+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?php
2+
3+
class ForgotPasswordUserInputException extends Exception
4+
{
5+
}

application/loginwebpage.class.inc.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -221,15 +221,15 @@ protected function ForgotPwdGo()
221221

222222
if ($oUser != null) {
223223
if (!MetaModel::IsValidAttCode(get_class($oUser), 'reset_pwd_token')) {
224-
throw new Exception(Dict::S('UI:ResetPwd-Error-NotPossible'));
224+
throw new ForgotPasswordUserInputException(Dict::S('UI:ResetPwd-Error-NotPossible'));
225225
}
226226
if (!$oUser->CanChangePassword()) {
227-
throw new Exception(Dict::S('UI:ResetPwd-Error-FixedPwd'));
227+
throw new ForgotPasswordUserInputException(Dict::S('UI:ResetPwd-Error-FixedPwd'));
228228
}
229229

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

235235
// This token allows the user to change the password without knowing the previous one
@@ -255,13 +255,14 @@ protected function ForgotPwdGo()
255255

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

263-
} catch (Exception $e) {
264-
IssueLog::Info('Failed to process the forgot password request for user "'.$sAuthUser.'": '.$e->getMessage());
262+
} catch (ForgotPasswordApplicationException $e) {
263+
IssueLog::Error('Failed to process the forgot password request for user "' . $sAuthUser . '": ' . $e->getMessage());
264+
} catch (ForgotPasswordUserInputException $e) {
265+
IssueLog::Info('Failed to process the forgot password request for user "' . $sAuthUser . '": ' . $e->getMessage());
265266
}
266267

267268
$oTwigContext = new LoginTwigRenderer();

lib/composer/autoload_classmap.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -745,6 +745,8 @@
745745
'Firebase\\JWT\\JWTExceptionWithPayloadInterface' => $vendorDir . '/firebase/php-jwt/src/JWTExceptionWithPayloadInterface.php',
746746
'Firebase\\JWT\\Key' => $vendorDir . '/firebase/php-jwt/src/Key.php',
747747
'Firebase\\JWT\\SignatureInvalidException' => $vendorDir . '/firebase/php-jwt/src/SignatureInvalidException.php',
748+
'ForgotPasswordApplicationException' => $baseDir . '/application/exceptions/ForgotPasswordApplicationException.php',
749+
'ForgotPasswordUserInputException' => $baseDir . '/application/exceptions/ForgotPasswordUserInputException.php',
748750
'FunctionExpression' => $baseDir . '/core/oql/expression.class.inc.php',
749751
'FunctionOqlExpression' => $baseDir . '/core/oql/oqlquery.class.inc.php',
750752
'GraphEdge' => $baseDir . '/core/simplegraph.class.inc.php',

0 commit comments

Comments
 (0)