示例#1
0
 private function doRegister()
 {
     try {
         $userRepository = new UserRepository($this->storage);
         $user = UserFactory::create(new UniqueId(), $this->request->get('name'), $this->request->get('email'), $this->request->get('password'), new UserGroups($this->storage));
         $userRepository->insert($user);
     } catch (DataNotValid $e) {
         return $this->returnErrorMessages(['field' => $e->getFieldName(), 'message' => $e->getMessage()]);
     }
     return $this->app->redirect('/groups/index');
 }
示例#2
0
文件: Group.php 项目: mejt/Krauza
 public function getById($id) : GroupEntity
 {
     $result = $this->storage->query(function ($pdo, $operations) use($id) {
         $dbClass = $operations . '\\FetchData';
         $columns = ['owner_id', 'name'];
         return $dbClass::getByField($pdo, $columns, 'group', 'id', $id);
     });
     $userRepository = new User($this->storage);
     $owner = $userRepository->getById($result['owner_id']);
     $id = new UniqueId($id);
     return new GroupEntity($id, $owner, new GroupName($result['name']), new Fiches($this->storage));
 }
示例#3
0
 private function doLogin()
 {
     $user = null;
     try {
         $userRepository = new UserRepository($this->storage);
         $user = $userRepository->getByEmail($this->request->get('email'));
     } catch (RecordNotExists $e) {
         return $this->returnErrorMessages(['field' => 'email', 'message' => 'Email address is not exists']);
     }
     if (password_verify($this->request->get('password'), $user->getPassword())) {
         return $this->returnErrorMessages(['field' => 'password', 'message' => 'Password is wrong']);
     }
     $this->setCurrentUser($user);
     return $this->app->redirect('/groups/index');
 }