Trigger 401 HTTP error on authentication failure instead of 500

This commit is contained in:
Benjamin Renard 2024-08-03 09:04:49 +02:00
parent 11b67c53b3
commit 72abbb7371
Signed by: bn8
GPG key ID: 3E2E1CE1907115BC

View file

@ -446,8 +446,10 @@ class Url {
Tpl :: assign('request', self :: $request );
// Check authentication (if need)
if(self :: $request -> authenticated && !Auth::login(true))
Log :: fatal(I18n::_("Authentication required but fail to authenticate you."));
if(self :: $request -> authenticated && !Auth::login(true)) {
Log :: error(I18n::_("Authentication required but fail to authenticate you."));
self :: error_page(null, 401);
}
Hook::trigger('before_handling_request', array('request' => self :: $request));
$success = false;