示例#1
0
文件: user.php 项目: enygma/conftrack
     $this->view->render($response, 'user/register.twig', $data);
 });
 $app->post('/register', function ($request, $response, $args) {
     $data = [];
     $body = $request->getParsedBody();
     $user = new \Conftrack\Model\User($this->getContainer()->get('db'));
     $data = ['success' => false];
     $user->load(['password' => $body['password'], 'username' => $body['username'], 'name' => $body['full_name'], 'email' => $body['email'], 'status' => 'active']);
     try {
         $user->verify();
         $user->save();
         // $this->flash->addMessage('success', 'User created successfully!');
         $message = 'User created successfully!';
         $data['success'] = true;
     } catch (\Exception $e) {
         $message = "Error: " . implode("\n", $user->getMessages());
     }
     $type = $data['success'] == false ? 'danger' : 'success';
     $this->flash->addMessage($type, $message);
     $this->view->render($response, 'user/register.twig', $data);
 });
 $app->get('/dashboard', function ($request, $response, $args) {
     $data = [];
     $this->view->render($response, 'user/dashboard.twig', $data);
 });
 $app->get('/view/{userId}', function ($request, $response, $args) {
     $db = $this->getContainer()->get('db');
     $user = new \Conftrack\Model\User($db);
     $user->findById($args['userId']);
     $groups = new \Conftrack\Collection\Groups($db);
     $groups->findAll();