public function testHashing() { $this->assertNotEquals(trim(ae_Security::hash('lorem ipsum')), ''); $this->assertNotEquals(trim(ae_Security::hash('lorem')), trim(ae_Security::hash('ipsum'))); $this->assertNotEquals(trim(ae_Security::hash('lorem')), trim(ae_Security::hash('lorem'))); $this->assertTrue(ae_Security::verify('this is my test input', ae_Security::hash('this is my test input'))); }
public function testSetPasswordHash() { $u = new ae_UserModel(); $hash = ae_Security::hash('test pwd'); $u->setPasswordHash($hash); $this->assertTrue($u->getPasswordHash() === $hash); $u->setPasswordHash(123456); $this->assertTrue($u->getPasswordHash() === '123456'); $this->setExpectedException('Exception'); $u->setPasswordHash(''); }
/** * Create the user. * @return {int} ID of the new user. */ function createUser() { if (!isset($_POST['user-name-internal'], $_POST['user-name-external'], $_POST['user-permalink'], $_POST['user-password'])) { header('Location: ../admin.php?error=missing_data_for_user'); exit; } $permalink = trim($_POST['user-permalink']); $status = isset($_POST['user-status-suspended']) ? ae_UserModel::STATUS_SUSPENDED : ae_UserModel::STATUS_ACTIVE; $user = new ae_UserModel(); if (isset($_POST['edit-id'])) { if (!$user->load($_POST['edit-id'])) { return FALSE; } } $user->setNameInternal($_POST['user-name-internal']); $user->setNameExternal($_POST['user-name-external']); if ($permalink != '') { $user->setPermalink($permalink); } if ($_POST['user-password'] !== '') { $user->setPasswordHash(ae_Security::hash($_POST['user-password'])); } $user->setStatus($status); $user->save(); return $user->getId(); }