Skip to content

Commit

Permalink
Login feedback if user do not have offline access (#39561)
Browse files Browse the repository at this point in the history
  • Loading branch information
carlitorweb authored Feb 26, 2023
1 parent 20c24db commit 2a8b6bb
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions plugins/authentication/joomla/joomla.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
<?php

/**
* @package Joomla.Plugin
* @subpackage Authentication.joomla
*
* @copyright (C) 2006 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
* @phpcs:disable PSR1.Classes.ClassDeclaration.MissingNamespace
*/
* @package Joomla.Plugin
* @subpackage Authentication.joomla
*
* @copyright (C) 2006 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
* @phpcs:disable PSR1.Classes.ClassDeclaration.MissingNamespace
*/

use Joomla\CMS\Authentication\Authentication;
use Joomla\CMS\Helper\AuthenticationHelper;
Expand Down Expand Up @@ -87,14 +86,24 @@ public function onUserAuthenticate($credentials, $options, &$response)
$response->email = $user->email;
$response->fullname = $user->name;

// Set default status response to success
$_status = Authentication::STATUS_SUCCESS;
$_errorMessage = '';

if ($this->app->isClient('administrator')) {
$response->language = $user->getParam('admin_language');
} else {
$response->language = $user->getParam('language');

if ($this->app->get('offline') && !$user->authorise('core.login.offline')) {
// User do not have access in offline mode
$_status = Authentication::STATUS_FAILURE;
$_errorMessage = Text::_('JLIB_LOGIN_DENIED');
}
}

$response->status = Authentication::STATUS_SUCCESS;
$response->error_message = '';
$response->status = $_status;
$response->error_message = $_errorMessage;
} else {
// Invalid password
$response->status = Authentication::STATUS_FAILURE;
Expand Down

0 comments on commit 2a8b6bb

Please sign in to comment.