Beispiel #1
0
 public function process($data)
 {
     if ($this->isValid($data) !== true) {
         throw new C3op_Form_UserCreateException('Invalid data!');
     } else {
         $db = Zend_Registry::get('db');
         $userMapper = new C3op_Auth_UserMapper($db);
         $user = new C3op_Auth_User();
         $user->SetLogin($this->login->GetValue());
         $user->SetName($this->name->GetValue());
         $user->SetPassword($this->password->GetValue());
         $user->SetEmail($this->email->GetValue());
         $user->SetRole($this->role->GetValue());
         $userMapper->insert($user);
     }
 }
Beispiel #2
0
 public function authenticate()
 {
     //        $result = $this->db->fetchRow(
     //                sprintf(
     //                    'SELECT id FROM auth_users WHERE login = \'%s\' AND password = \'%s\';',
     //                    $this->login,
     //                    $this->scrambleWithToken($this->password)
     //                    )
     //                );
     $userMapper = new C3op_Auth_UserMapper($this->db);
     $user = $userMapper->authenticateUser($this->login, $this->password);
     if ($user instanceof C3op_Auth_User && $user->GetID() > 0) {
         $this->user = $user;
         return new Zend_Auth_Result(Zend_Auth_Result::SUCCESS, $user, array());
     } else {
         $this->user = null;
         return new Zend_Auth_Result(Zend_Auth_Result::FAILURE, null, array('Authentication unsuccessful'));
     }
 }
Beispiel #3
0
 public function process($data)
 {
     $db = Zend_Registry::get('db');
     $userMapper = new C3op_Auth_UserMapper($db);
     if ($this->isValid($data) !== true) {
         throw new C3op_Form_UserEditException('Invalid data!');
     } else {
         $id = $data['id'];
         $user = $userMapper->findById($id);
         $user->SetName($data['name']);
         $user->SetLogin($data['login']);
         $user->SetEmail($data['email']);
         $user->SetRole($data['role']);
         if ($data['password'] != "") {
             $user->SetPassword($data['password']);
         }
         $userMapper->update($user);
     }
 }
Beispiel #4
0
 private function InitUserWithCheckedId(C3op_Auth_UserMapper $mapper)
 {
     return $mapper->findById($this->checkIdFromGet());
 }