Skip to content

Commit

Permalink
Merge pull request #2 from joomlatools/feature/cleanup
Browse files Browse the repository at this point in the history
Cleanup
  • Loading branch information
amazeika authored Jul 2, 2019
2 parents c8605cd + 2e657b0 commit 177f41c
Showing 1 changed file with 8 additions and 20 deletions.
28 changes: 8 additions & 20 deletions basicauth.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,30 +81,18 @@ public function onAfterRoute()
*/
protected function _login($username, $password, $application)
{
// If we did receive the user credentials from the user, try to login
if($application->login(array('username' => $username, 'password' => $password)) !== true) {
return false;
}
$result = false;

// If we have logged in succesfully, make sure to fullfil
// Koowa's CSRF authenticator checks if the framework is loaded.
if (class_exists('Koowa'))
// If we did receive the user credentials from the user, try to login
if($application->login(array('username' => $username, 'password' => $password)) === true)
{
$manager = KObjectManager::getInstance();

$request = $manager->getInstance()->getObject('com:koowa.dispatcher.request');
$user = $manager->getInstance()->getObject('user');
$token = $user->getSession()->getToken();


// Explicitly authenticate user
$user->setAuthentic();
if (class_exists('Koowa')) {
KObjectManager::getInstance()->getObject('user')->setAuthentic(); // Explicitly authenticate user
}

//$request->setReferrer(JUri::root());
$request->getHeaders()->add(array('X-Xsrf-Token' => $token));
$request->getCookies()->add(array('csrf_token' => $token));
$result = true;
}

return true;
return $result;
}
}

0 comments on commit 177f41c

Please sign in to comment.