/**
  * Output the general information about the user
  *
  * @param array $options Command line options
  * @param OutputInterface $output Output interface object
  */
 public function showUserGeneral(array $options = array(), $output)
 {
     $params = array();
     if (!empty($options['id'])) {
         $params['id'] = $options['id'];
     }
     $columns = array('username' => 'Username', 'password' => 'Password', 'email' => 'Email', 'firstName' => 'First Name', 'lastName' => 'Last Name', 'created' => 'Date Created', 'updated' => 'Date Updated', 'status' => 'Status', 'id' => 'ID');
     $users = Gatekeeper::findUsers($params);
     $this->buildTable($columns, $users->toArray(true), $output);
 }
Exemple #2
0
use Psecio\Gatekeeper\Gatekeeper as g;
$app->group('/user', function () use($app, $view) {
    $app->get('/', function () use($app, $view) {
        $users = g::findUsers();
        $view->render('json.php', $users->toArray(true));
    });
    $app->get('/:id', function ($id) use($app, $view) {
        $user = g::findUserById($id);
        $view->render('json.php', $user->toArray());
    });
});
// Pages
$app->group('/users', function () use($app, $view) {
    $app->get('/', function () use($app, $view) {
        $users = g::findUsers();
        $data = array('users' => $users->toArray(true));
        echo $view->render('users/index.php', $data);
    });
    $app->post('/add', function () use($app, $view) {
        $data = $app->request->post();
        try {
            // Verify the emails match
            if ($data['password'] !== $data['password-confirm']) {
                throw new \Exception('Password mismatch!');
            }
            $result = g::createUser(array('username' => $data['username'], 'password' => $data['password'], 'email' => $data['email'], 'first_name' => $data['first-name'], 'last_name' => $data['last-name']));
            if ($result === false) {
                throw new \Exception('Error creating user');
            }
        } catch (\Exception $e) {
Exemple #3
0
 public function listUsers()
 {
     echo $this->twig->render('users/list.twig', ['users' => Gatekeeper::findUsers()]);
 }