Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update login.php for two-factor authentication support #132

Open
wants to merge 2 commits into
base: release-2.5.3
Choose a base branch
from
Open
Changes from all 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
10 changes: 8 additions & 2 deletions code/site/libraries/authentication/login.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,15 @@ public function authenticate()

$username = $app->input->post->get('username', '', 'STRING');
$password = $app->input->post->get('password', '', 'STRING');
$secret = $app->input->post->get('secretkey', '', 'STRING');

$userId = $this->loadUserByCredentials($username, $password);

// Remove username and password from request for when it gets logged
$uri = JFactory::getURI();
$uri->delVar('username');
$uri->delVar('password');
$uri->delVar('secretkey');

if ($userId === false)
{
Expand All @@ -57,18 +59,22 @@ public function authenticate()
*
* @param STRING $user user
* @param STRING $pass pass
* @param STRING $secret secretkey
*
* @return int
*
* @since 1.6
*/
public function loadUserByCredentials($user, $pass)
public function loadUserByCredentials($user, $pass, $secret = NULL)
{
jimport('joomla.user.authentication');

$authenticate = JAuthentication::getInstance();

$response = $authenticate->authenticate(array('username' => $user, 'password' => $pass), $options = array());
// $response = $authenticate->authenticate(array('username' => $user, 'password' => $pass), $options = array());
// adding support for two factor authentication

$response = $authenticate->authenticate(array('username' => $user, 'password' => $pass, 'secretkey' => $secret), $options = array());

if ($response->status === JAuthentication::STATUS_SUCCESS)
{
Expand Down