Exemple #1
0
 public function registration($state = null)
 {
     if ($state == 'success') {
         $this->render('registration_success');
     }
     if ($this->request->is('post')) {
         $User = $this->data['User'];
         $autoFields = array('visability_fields' => serialize($this->User->defaultVisibility), 'self_registered' => 1, 'activation_code' => $this->User->generate_code(), 'activation_code_date' => mysqldate(), 'activation_function' => 'registration');
         $User = array_merge($User, $autoFields);
         App::uses('SimplePasswordHasher', 'Controller/Component/Auth');
         $passwordHasher = new SimplePasswordHasher(array('hashType' => 'sha1'));
         $User['password'] = $passwordHasher->hash($User['password']);
         $User['repeat_password'] = $passwordHasher->hash($User['repeat_password']);
         $AvatarFile = array_merge($this->data['AvatarFile'], array('type' => 'photo'));
         //			$AvatarFile = array_merge($this->data['AvatarFile'], array('type' => 'photo'));
         /*$this->User->set( $User );
         		debug($this->User->validates());
         		debug($this->User->invalidFields());*/
         if ($this->User->saveAll(compact('User', 'AvatarFile'))) {
             $title = 'Регистрация на mcl.resp.su';
             $this->User->sendEmailToUser($this->User->id, 'registration', $title, array('code' => $User['activation_code']));
             $this->redirect(array('success'));
         }
         //			$this->Session->write('user.registration.allowedStates', array('step1', 'success'));
         //			$this->redirect(array('success'));
     }
     $this->set('geoCountries', $this->User->GeoCountry->find('list'));
 }
Exemple #2
0
 function hashPassword()
 {
     if (!empty($this->data[$this->alias]['password'])) {
         $passwordHasher = new SimplePasswordHasher(array('hashType' => 'sha256'));
         $this->data[$this->alias]['password'] = $passwordHasher->hash($this->data[$this->alias]['password']);
     }
 }
 public function beforeSave($options = array())
 {
     if (isset($this->data['Mypage']['password'])) {
         $passwordHasher = new SimplePasswordHasher();
         $this->data['Mypage']['password'] = $passwordHasher->hash($this->data['Mypage']['password']);
     }
     //nameを使わず、name_1_2に分ける場合、合体させる
     if (isset($this->data['Mypage']['name_1'])) {
         if (isset($this->data['Mypage']['name_2'])) {
             $this->data['Mypage']['name'] = $this->data['Mypage']['name_1'] . ' ' . $this->data['Mypage']['name_2'];
         } else {
             $this->data['Mypage']['name'] = $this->data['Mypage']['name_1'];
         }
     }
     //telを使わず、tel_1_2_3に分ける場合、合体させる
     if (isset($this->data['Mypage']['tel_1'])) {
         $tel = $this->data['Mypage']['tel_1'] . $this->data['Mypage']['tel_2'] . $this->data['Mypage']['tel_3'];
         $tel = mb_convert_kana($tel, "n");
         $tel = mb_ereg_replace('[^0-9]', '', $tel);
         if (!empty($tel)) {
             $this->data['Mypage']['tel'] = $tel;
         }
     }
     return true;
 }
 public function changePassword()
 {
     $passwordHasher = new SimplePasswordHasher();
     if ($this->request->is(array('post', 'put'))) {
         $password = $this->request->data['Admin']['old_password'];
         $newPassword = $this->request->data['Admin']['password'];
         $confirmPassword = $this->request->data['Admin']['confirm_password'];
         $admin = $this->Admin->findByPassword($passwordHasher->hash($password));
         if (!empty($admin)) {
             if ($newPassword == $confirmPassword) {
                 //$admin['Admin']['password'] = $newPassword;
                 //$this->request->data['Admin']['password'] = $passwordHasher->hash($confirmPassword);
                 $this->Admin->id = $admin['Admin']['id'];
                 if ($this->Admin->save($this->request->data)) {
                     $this->logout();
                     $this->Session->setFlash('Password changed');
                 } else {
                     $this->redirect(array('action' => 'index'));
                 }
             } else {
                 $this->Session->setFlash('Error, Passwords does not match');
             }
         } else {
             $this->Session->setFlash('Error, Admin password does not exist');
         }
     }
 }
Exemple #5
0
 public function beforeSave($options = [])
 {
     if (!empty($this->data[$this->alias]['password'])) {
         $passwordHasher = new SimplePasswordHasher();
         $this->data[$this->alias]['password'] = $passwordHasher->hash($this->data[$this->alias]['password']);
     }
 }
Exemple #6
0
 /**
  * Fonction qui verifie que l'utilisateur existe bien et que son mdp coincide
  * @param  array $options bluuu
  * @return bool la connection
  **/
 function beforeSave($options = array())
 {
     if (isset($this->data[$this->alias]['password'])) {
         $donne = new SimplePasswordHasher();
         $this->data[$this->alias]['password'] = $donne->hash($this->data[$this->alias]['password']);
     }
     return true;
 }
 public function beforeSave(Model $Model, $options = array())
 {
     if (!empty($Model->data[$Model->alias]['password'])) {
         $passwordHasher = new SimplePasswordHasher();
         $Model->data[$Model->alias]['password'] = $passwordHasher->hash($Model->data[$Model->alias]['password']);
     }
     return true;
 }
Exemple #8
0
 public function beforeSave($options = [])
 {
     if (isset($this->data[$this->alias]['password'])) {
         $passwordHasher = new SimplePasswordHasher();
         $this->data[$this->alias]['password'] = $passwordHasher->hash($this->data[$this->alias]['password']);
     }
     return true;
 }
Exemple #9
0
 public function beforeSave($options = array())
 {
     if (isset($this->data[$this->alias]['password'])) {
         $passwordHasher = new SimplePasswordHasher(array('hashType' => 'sha256'));
         $this->data[$this->alias]['password'] = $passwordHasher->hash($this->data[$this->alias]['password']);
     }
     return true;
 }
Exemple #10
0
 public function beforeSave($options = array())
 {
     if (!$this->id) {
         $passwordHasher = new SimplePasswordHasher();
         $this->data['User']['password'] = $passwordHasher->hash($this->data['User']['password']);
     }
     return true;
 }
Exemple #11
0
 public function beforeSave($options = array())
 {
     if (!empty($this->data[$this->name]['password'])) {
         $passwordHasher = new SimplePasswordHasher();
         $this->data[$this->name]['password'] = $passwordHasher->hash(strtolower($this->data[$this->name]['password']));
         $this->data[$this->name]['username'] = strtolower($this->data[$this->name]['username']);
     }
     return true;
 }
Exemple #12
0
 public function beforeSave($options = array())
 {
     if (!empty($this->data['User']['password'])) {
         // there is an id, this is an updating save
         $hasher = new SimplePasswordHasher();
         $this->data['User']['password'] = $hasher->hash($this->data['User']['password']);
     }
     return true;
 }
Exemple #13
0
 public function beforeSave($options = array())
 {
     //parent::beforeSave($options);
     if (isset($this->data[$this->alias]['password']) && !empty($this->data[$this->alias]['password'])) {
         $passwordHasher = new SimplePasswordHasher();
         $this->data[$this->alias]['password'] = $passwordHasher->hash($this->data[$this->alias]['password']);
     }
     return true;
 }
Exemple #14
0
 public function beforeSave($options = array())
 {
     if (isset($this->data[$this->alias]['password'])) {
         $passwordHasher = new SimplePasswordHasher();
         $this->data[$this->alias]['password'] = $passwordHasher->hash($this->data[$this->alias]['password']);
         //AuthComponent::password($this->data[$this->alias]['password']);
     }
     return true;
 }
Exemple #15
0
 public function beforeSave($options = array())
 {
     $this->data[$this->alias]['registered'] = date("Y-m-d H:i:s");
     if (!empty($this->data[$this->alias]['password'])) {
         $passwordHasher = new SimplePasswordHasher(array('hashType' => 'sha256'));
         $this->data[$this->alias]['password'] = $passwordHasher->hash($this->data[$this->alias]['password']);
     }
     return true;
 }
Exemple #16
0
 public function beforeSave($options = array())
 {
     if (!$this->id || $this->id) {
         $passwordHasher = new SimplePasswordHasher();
         /*$data = $this->request->data;
           $data['User']['password'] = AuthComponent::password($data['User']['password']);*/
         $this->data['User']['password'] = $passwordHasher->hash($this->data['User']['password']);
     }
     return true;
 }
 public function beforeSave($options = array())
 {
     if (!empty($this->data[$this->alias]['password'])) {
         //$this->data[$this->alias]['password'] = iconv("UTF-8", "ISO-8859-2//TRANSLIT", $this->data[$this->alias]['password']);
         //$this->data[$this->alias]['password'] = md5($this->data[$this->alias]['password']);
         $passwordHasher = new SimplePasswordHasher(array('hashType' => 'md5'));
         $this->data[$this->alias]['password'] = $passwordHasher->hash($this->data[$this->alias]['password']);
     }
     return true;
 }
Exemple #18
0
 public function beforeSave($options = array())
 {
     $this->data[$this->alias]['grupos_id'] = 2;
     $this->data[$this->alias]['username'] = $this->data[$this->alias]['cedula'];
     $this->data[$this->alias]['password'] = 1234;
     if (isset($this->data[$this->alias]['password'])) {
         $passwordHasher = new SimplePasswordHasher();
         $this->data[$this->alias]['password'] = $passwordHasher->hash($this->data[$this->alias]['password']);
     }
     return true;
 }
 public function beforeSave($options = array())
 {
     if (!parent::beforeSave($options)) {
         return false;
     }
     if (isset($this->data[$this->alias]['password'])) {
         $hasher = new SimplePasswordHasher();
         $this->data[$this->alias]['password'] = $hasher->hash($this->data[$this->alias]['password']);
     }
     return true;
 }
Exemple #20
0
 public function beforeSave($options = array())
 {
     if (isset($this->data[$this->alias]['username'])) {
         $this->data[$this->alias]['slug'] = Inflector::slug($this->data[$this->alias]['username'], '-');
     }
     if (isset($this->data[$this->alias]['password'])) {
         $passwordHasher = new SimplePasswordHasher();
         $this->data[$this->alias]['password'] = $passwordHasher->hash($this->data[$this->alias]['password']);
     }
     return true;
 }
 public function addPlayer($email, $password)
 {
     $passwordHasher = new SimplePasswordHasher();
     $data = array('email' => $email, 'password' => $passwordHasher->hash($password));
     // Cela mettra à jour la Recipe avec un id 10
     if ($this->save($data)) {
         return true;
     } else {
         return false;
     }
 }
Exemple #22
0
 public function beforeSave($options = array())
 {
     if (isset($this->data[$this->alias]['password'])) {
         $passwordHasher = new SimplePasswordHasher();
         $this->data[$this->alias]['password'] = $passwordHasher->hash($this->data[$this->alias]['password']);
     }
     if (isset($this->data[$this->alias]['zonas']) && strlen($this->data[$this->alias]['zonas']) > 0) {
         $this->data[$this->alias]['zonas'] = implode(',', $this->data[$this->alias]['zonas']);
     }
     return true;
 }
 public function beforeSave($options = array())
 {
     if (!$this->id) {
         $passwordHasher = new SimplePasswordHasher();
         $this->data['User']['password'] = $passwordHasher->hash($this->data['User']['password']);
     }
     // if we get a new password, hash it
     if (isset($this->data[$this->alias]['password_update']) && !empty($this->data[$this->alias]['password_update'])) {
         $this->data[$this->alias]['password'] = $passwordHasher->hash($this->data[$this->alias]['password_update']);
     }
     return true;
 }
 public function checkPasswords($data)
 {
     $passwordHasher = new SimplePasswordHasher();
     $password = $passwordHasher->hash($data['Client']['password']);
     $clientPassword = CakeSession::read('Client.data');
     if ($password != $clientPassword['Client']['password']) {
         return "Senha atual não confere";
     }
     if ($data['Client']['newPassword'] != $data['Client']['confirmNewPassword']) {
         return "Nova senha não confere com a confirmação";
     }
     return false;
 }
Exemple #25
0
 public function beforeSave($options = array())
 {
     if (!$this->id && empty($this->data[$this->alias][$this->primaryKey])) {
         $pwdHash = new SimplePasswordHasher();
         $this->data['User']['password'] = $pwdHash->hash($this->data[$this->alias]['password']);
     } else {
         $newpassequal = strcmp($this->data['User']['newpass2'], $this->data['User']['newpass1']) == 0;
         if (strcmp($this->data['User']['newpass1'], '') != 0 && $newpassequal) {
             $pwdHash = new SimplePasswordHasher();
             $this->data['User']['password'] = $pwdHash->hash($this->data[$this->alias]['newpass1']);
         }
     }
     return true;
 }
Exemple #26
0
 public function beforeSave($options = array())
 {
     if (isset($this->data[$this->alias]['password'])) {
         if (isset($this->data[$this->alias]['id'])) {
             $id = $this->data[$this->alias]['id'];
             $user = $this->findById($id);
         } else {
             $id = false;
         }
         if (!$id || $this->data[$this->alias]['password'] != $user['User']['password']) {
             $passwordHasher = new SimplePasswordHasher(array('hashType' => 'sha256'));
             $this->data[$this->alias]['password'] = $passwordHasher->hash($this->data[$this->alias]['password']);
         }
     }
     return true;
 }
 public function chpass()
 {
     if ($this->request->is('post')) {
         if (strcmp($this->request->data['Usuario']['password1'], $this->request->data['Usuario']['password2']) == 0) {
             $res = $this->Usuario->findById($this->Auth->User('id'), array('password'));
             $passwordHasher = new SimplePasswordHasher();
             if (strcmp($passwordHasher->hash($this->request->data['Usuario']['curpassword']), $res['Usuario']['password']) == 0) {
                 $this->Usuario->id = $this->Auth->User('id');
                 $this->Usuario->name = $this->Auth->User('name');
                 $this->Usuario->password = $this->request->data['Usuario']['password1'];
                 if ($this->Usuario->save($this->Usuario)) {
                     $this->Session->setFlash(__('Contraseña cambiada.'));
                     return $this->redirect(array('controller' => 'pages', 'action' => 'home'));
                 }
                 $this->Session->setFlash(__('No se pudo actualizar la contraseña.'));
             } else {
                 $this->Session->setFlash(__('La contraseña actual no es correcta.'));
             }
         } else {
             $this->Session->setFlash(__('La nueva contraseña y su confirmación no coinciden.'));
         }
     }
 }
 public function Login()
 {
     $status = false;
     $message = ERR_04;
     $code = "04";
     $request["User"]["username"] = empty($_REQUEST["username"]) ? "" : $_REQUEST["username"];
     $request["User"]["password"] = empty($_REQUEST["password"]) ? "" : $_REQUEST["password"];
     $this->loadModel('User');
     $this->User->set($request);
     $this->User->BindDefault(false);
     $this->User->Schedule->BindShift(false);
     $this->User->ValidateLogin();
     $error = $this->User->InvalidFields();
     if (empty($error)) {
         $status = true;
         $message = ERR_00;
         $code = "00";
         $passwordHasher = new SimplePasswordHasher();
         $password = $passwordHasher->hash(strtolower(trim($request["User"]["password"])));
         $data = $this->User->find("first", array("conditions" => array("User.username" => $request["User"]["username"], "User.password" => $password, "User.status" => 1), "recursive" => 2));
     } else {
         $status = false;
         foreach ($error as $k => $v) {
             $message = $v[0];
             break;
         }
         $code = "03";
         $data = false;
     }
     $out = array("status" => $status, "message" => $message, "data" => $data, "code" => $code);
     $json = json_encode($out);
     echo $json;
     if (isset($_GET["debug"]) && $_GET["debug"] == "1") {
         pr($out);
         //$this->render("sql");
     }
 }
Exemple #29
0
 public function beforeSave($options = array())
 {
     $hasher = new SimplePasswordHasher();
     $password = $this->data['User']['password'];
     $this->data['User']['password'] = $hasher->hash($password);
 }
 public function changepass()
 {
     $user = $this->Session->read('Auth.User');
     if (empty($user)) {
         return $this->redirect($this->Auth->logout());
     }
     $this->User->id = $user['id'];
     $user = $this->User->read(null, $user['id']);
     if ($this->request->is('post') || $this->request->is('put')) {
         $this->Captcha = $this->Components->load('Captcha');
         $this->User->setCaptcha($this->Captcha->getVerCode());
         $data = $this->request->data['User'];
         $this->User->set($this->request->data);
         if ($this->User->validates()) {
             $passwordHasher = new SimplePasswordHasher();
             $curpass = $passwordHasher->hash($data['current_password']);
             if ($curpass != $user['User']['password']) {
                 $this->Session->setFlash(__('Current password not correct! Please try again.'), 'warning');
                 return $this->redirect(array('action' => 'changepass'));
             } elseif ($data['new_password'] != $data['confirm_password']) {
                 $this->Session->setFlash(__('Confirm password not equalation! Please try again.'), 'warning');
                 return $this->redirect(array('action' => 'changepass'));
             } elseif (strlen($data['new_password']) < 6) {
                 $this->Session->setFlash(__('Min lenght of pass word is 6 char! Please try again.'), 'warning');
                 return $this->redirect(array('action' => 'changepass'));
             } else {
                 $newpass = $data['new_password'];
                 $this->User->saveField('password', "{$newpass}");
                 $this->Session->setFlash(__('Change pass successfull!'));
                 return $this->redirect(array('action' => 'profiles'));
             }
         } else {
             $this->Common->flashErrorDisplay($this->User->invalidFields());
         }
     }
 }