mirror of
https://github.com/e107inc/e107.git
synced 2025-03-14 17:39:46 +01:00
Simple login test added.
This commit is contained in:
parent
78a70b687d
commit
67e7823a60
@ -96,7 +96,7 @@ class userlogin
|
||||
|
||||
$autologin = intval($autologin); // Will decode to zero if forced login
|
||||
$authorized = false;
|
||||
if (!$forceLogin && $this->e107->isInstalled('alt_auth'))
|
||||
if (!$forceLogin && e107::isInstalled('alt_auth'))
|
||||
{
|
||||
$authMethod[0] = varset($pref['auth_method'], 'e107'); // Primary authentication method
|
||||
$authMethod[1] = varset($pref['auth_method2'], 'none'); // Secondary authentication method (if defined)
|
||||
@ -291,7 +291,11 @@ class userlogin
|
||||
}
|
||||
}
|
||||
|
||||
if($noredirect) return true;
|
||||
if($noredirect)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
$redir = e_REQUEST_URL;
|
||||
//$redir = e_SELF;
|
||||
//if (e_QUERY) $redir .= '?'.str_replace('&','&',e_QUERY);
|
||||
@ -521,13 +525,16 @@ class userlogin
|
||||
'LOGIN_DB_ERROR'=> -12, // Error adding user to main DB
|
||||
);
|
||||
|
||||
$ret = [];
|
||||
foreach($errors as $k=>$v)
|
||||
{
|
||||
$this->invalidLogin("John Smith", $v, 'Custom error text');
|
||||
echo "<h4>".$k."</h4>";
|
||||
echo e107::getMessage()->render();
|
||||
$ret[] = $this->invalidLogin("John Smith", $v, 'Custom error text');
|
||||
// echo "<h4>".$k."</h4>";
|
||||
// $ret[] = e107::getMessage()->render();
|
||||
}
|
||||
|
||||
return $ret;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -537,7 +544,7 @@ class userlogin
|
||||
*/
|
||||
protected function invalidLogin($username, $reason, $extra_text = '')
|
||||
{
|
||||
global $pref, $sql;
|
||||
global $pref;
|
||||
|
||||
$doCheck = FALSE; // Flag set if need to ban check
|
||||
$this->userData = array();
|
||||
@ -633,7 +640,7 @@ class userlogin
|
||||
{
|
||||
if($pref['autoban'] == 1 || $pref['autoban'] == 3) // Flood + Login or Login Only.
|
||||
{
|
||||
$fails = $sql->count("generic", "(*)", "WHERE gen_ip='{$this->userIP}' AND gen_type='failed_login' ");
|
||||
$fails = e107::getDb()->count("generic", "(*)", "WHERE gen_ip='{$this->userIP}' AND gen_type='failed_login' ");
|
||||
|
||||
$failLimit = vartrue($pref['failed_login_limit'],10);
|
||||
|
||||
|
@ -687,6 +687,11 @@ class UserHandler
|
||||
*/
|
||||
public function makeUserCookie($lode,$autologin = false)
|
||||
{
|
||||
if(e107::isCli())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
$cookieval = $lode['user_id'].'.'.md5($lode['user_password']); // (Use extra md5 on cookie value to obscure hashed value for password)
|
||||
if (e107::getPref('user_tracking') == 'session')
|
||||
{
|
||||
|
78
e107_tests/tests/unit/userloginTest.php
Normal file
78
e107_tests/tests/unit/userloginTest.php
Normal file
@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
|
||||
class userloginTest extends \Codeception\Test\Unit
|
||||
{
|
||||
|
||||
/** @var userlogin */
|
||||
protected $lg;
|
||||
|
||||
protected function _before()
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
$this->lg = $this->make('userlogin');
|
||||
}
|
||||
|
||||
catch(Exception $e)
|
||||
{
|
||||
$this->assertTrue(false, $e->getMessage());
|
||||
}
|
||||
|
||||
$this->lg->__construct();
|
||||
|
||||
}
|
||||
/*
|
||||
public function testGetUserData()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function testGetLookupQuery()
|
||||
{
|
||||
|
||||
}
|
||||
*/
|
||||
public function testLogin()
|
||||
{
|
||||
$tests = array(
|
||||
0 => array(
|
||||
'username' => 'invalid_user',
|
||||
'userpass' => '',
|
||||
'autologin' => 0,
|
||||
'noredirect' => true,
|
||||
'response' => '',
|
||||
'_expected_' => false
|
||||
),
|
||||
1 => array(
|
||||
'username' => 'e107',
|
||||
'userpass' => 'e107',
|
||||
'autologin' => 0,
|
||||
'noredirect' => true,
|
||||
'response' => '',
|
||||
'_expected_' => true
|
||||
),
|
||||
);
|
||||
|
||||
foreach($tests as $var)
|
||||
{
|
||||
$result = $this->lg->login($var['username'], $var['userpass'], $var['autologin'], $var['response'], $var['noredirect']);
|
||||
$this->assertSame($var['_expected_'], $result);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function testErrorMessages()
|
||||
{
|
||||
$result = $this->lg->test();
|
||||
|
||||
foreach($result as $var)
|
||||
{
|
||||
$this->assertNotEmpty($var);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user