Esempio n. 1
0
 public function validate($action)
 {
     $token_validator = \Core::make('helper/validation/token');
     if (!$token_validator->validate($action)) {
         $r = new UserEditResponse();
         $r->setError(new \Exception('Invalid Token.'));
         $r->outputJSON();
         \Core::shutdown();
     }
 }
Esempio n. 2
0
 public function change_password($uID = false)
 {
     $this->setupUser($uID);
     if ($this->canEditPassword) {
         $password = $this->post('uPassword');
         $passwordConfirm = $this->post('uPasswordConfirm');
         \Core::make('validator/password')->isValid($password, $this->error);
         if (!Loader::helper('validation/token')->validate('change_password')) {
             $this->error->add(Loader::helper('validation/token')->getErrorMessage());
         }
         if ($password != $passwordConfirm) {
             $this->error->add(t('The two passwords provided do not match.'));
         }
         $sr = new UserEditResponse();
         $sr->setUser($this->user);
         if (!$this->error->has()) {
             $data['uPassword'] = $password;
             $data['uPasswordConfirm'] = $passwordConfirm;
             $this->user->update($data);
             $sr->setMessage(t('Password updated successfully.'));
         } else {
             $sr->setError($this->error);
         }
         $sr->outputJSON();
     }
 }
Esempio n. 3
0
 public function change_password($uID = false)
 {
     $this->setupUser($uID);
     if ($this->canEditPassword) {
         $password = $this->post('uPassword');
         $passwordConfirm = $this->post('uPasswordConfirm');
         if (strlen($password) < Config::get('concrete.user.password.minimum') || strlen($password) > Config::get('concrete.user.password.maximum')) {
             $this->error->add(t('A password must be between %s and %s characters', Config::get('concrete.user.password.minimum'), Config::get('concrete.user.password.maximum')));
         }
         if (!Loader::helper('validation/token')->validate('change_password')) {
             $this->error->add(Loader::helper('validation/token')->getErrorMessage());
         }
         if (strlen($password) >= Config::get('concrete.user.password.minimum') && !Loader::helper('concrete/validation')->password($password)) {
             $this->error->add(t('A password may not contain ", \', >, <, or any spaces.'));
         }
         if ($password != $passwordConfirm) {
             $this->error->add(t('The two passwords provided do not match.'));
         }
         $sr = new UserEditResponse();
         $sr->setUser($this->user);
         if (!$this->error->has()) {
             $data['uPassword'] = $password;
             $data['uPasswordConfirm'] = $passwordConfirm;
             $this->user->update($data);
             $sr->setMessage(t('Password updated successfully.'));
         } else {
             $sr->setError($this->error);
         }
         $sr->outputJSON();
     }
 }