/** * Test that the system rejects invalid passwords */ public function testInvalidPasswords() { $this->setExpectedException('TaskerMAN\\Application\\UserManagementException'); $passwords = array('nospecial', 'this_is_too_long_sozthis_is_too_long_sozthis_is_too_long_sozthis_is_too_long_soz', 'numb3rs'); foreach ($passwords as $password) { $this->assertFalse(TaskerMAN\Application\UserManagement::validatePassword($password)); } }
/** * Test user creation */ public function testCreateUser() { $uid = TaskerMAN\Application\UserManagement::create($this->email, $this->name, $this->password, $this->admin); // Test that user was created correctly $this->assertTrue(is_numeric($uid)); // Test loading the user $this->loadUser($uid); // Test that they can log in $this->login($uid); // Delete test user $this->deleteUser($uid); }
} catch (TaskerMAN\Application\UserManagementException $e) { $alert = '<div class="alert alert-danger" role="alert">' . $e->getMessage() . '</div>'; } } elseif (isset($_POST['submit'])) { // Form submitted if (isset($_POST['admin'])) { $is_admin = true; } else { $is_admin = false; } // Update user try { TaskerMAN\Application\UserManagement::update($user->id, TaskerMAN\Core\IO::POST('name'), TaskerMAN\Core\IO::POST('email'), $is_admin); // Update password if (!empty(TaskerMAN\Core\IO::POST('password'))) { TaskerMAN\Application\UserManagement::changePassword($user->id, TaskerMAN\Core\IO::POST('password')); } // Reload user $user = new TaskerMAN\Application\User($uid); $alert = '<div class="alert alert-info" role="alert">User settings were succesfully updated</div>'; } catch (TaskerMAN\Application\UserManagementException $e) { $alert = '<div class="alert alert-danger" role="alert">' . $e->getMessage() . '</div>'; } } ?> <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main"> <?php if (isset($alert)) { echo $alert;
<?php // Hide default template TaskerMAN\WebInterface\WebInterface::showTemplate(false); // Intialize installation engine $install = new TaskerMAN\Core\Install(); if (!$install->required()) { throw new TaskerMAN\Core\FatalException('Install Not Required', new \Exception('All database tables already exist, so an install is not required.')); } $alert = null; if (isset($_POST['submit'])) { // Create tables $install->createTables(); // Create user try { $uid = TaskerMAN\Application\UserManagement::create(TaskerMAN\Core\IO::POST('email'), TaskerMAN\Core\IO::POST('name'), TaskerMAN\Core\IO::POST('password'), true); header('Location: index.php?p=user&id=' . $uid); } catch (TaskerMAN\Application\UserManagementException $e) { $alert = '<div class="alert alert-danger" role="alert">' . $e->getMessage() . '</div>'; } } ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Install · TaskerMAN</title>