Trim username and password
This commit is contained in:
parent
56d21dc726
commit
818c501b07
@ -9,6 +9,8 @@ const TABLE = 'users';
|
|||||||
|
|
||||||
function create_user($username, $password, $is_admin = false)
|
function create_user($username, $password, $is_admin = false)
|
||||||
{
|
{
|
||||||
|
$username = trim($username);
|
||||||
|
$password = trim($password);
|
||||||
list($fever_token, $fever_api_key) = generate_fever_api_key($username);
|
list($fever_token, $fever_api_key) = generate_fever_api_key($username);
|
||||||
|
|
||||||
return Database::getInstance('db')
|
return Database::getInstance('db')
|
||||||
|
@ -61,6 +61,17 @@ class UserModelTest extends BaseTest
|
|||||||
$this->assertNotEquals('test', $user['password']);
|
$this->assertNotEquals('test', $user['password']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testCreateUserWithTrailingSpaces()
|
||||||
|
{
|
||||||
|
$this->assertEquals(2, Model\User\create_user('foobar ', ' test'));
|
||||||
|
|
||||||
|
$user = Model\User\get_user_by_id(2);
|
||||||
|
$this->assertEquals(2, $user['id']);
|
||||||
|
$this->assertEquals('foobar', $user['username']);
|
||||||
|
$this->assertEquals(0, $user['is_admin']);
|
||||||
|
$this->assertTrue(password_verify('test', $user['password']));
|
||||||
|
}
|
||||||
|
|
||||||
public function testRemoveUser()
|
public function testRemoveUser()
|
||||||
{
|
{
|
||||||
$this->assertEquals(2, Model\User\create_user('foobar', 'test'));
|
$this->assertEquals(2, Model\User\create_user('foobar', 'test'));
|
||||||
|
Loading…
Reference in New Issue
Block a user