fix: Fix to an issue with default values not set by the beforeValidate of users

pull/1260/head
Iglocska 2016-06-13 03:15:08 +02:00
parent 4dd5df53c8
commit 6a07ce7b73
1 changed files with 2 additions and 2 deletions

View File

@ -264,12 +264,12 @@ class User extends AppModel {
public function beforeValidate($options = array()) { public function beforeValidate($options = array()) {
if (!isset($this->data['User']['id'])) { if (!isset($this->data['User']['id'])) {
if (isset($this->data['User']['enable_password']) && (!$this->data['User']['enable_password'] || (empty($this->data['User']['password']) && empty($this->data['User']['confirm_password'])))) { if ((isset($this->data['User']['enable_password']) && (!$this->data['User']['enable_password'])) || (empty($this->data['User']['password']) && empty($this->data['User']['confirm_password']))) {
$this->data['User']['password'] = $this->__generatePassword(); $this->data['User']['password'] = $this->__generatePassword();
$this->data['User']['confirm_password'] = $this->data['User']['password']; $this->data['User']['confirm_password'] = $this->data['User']['password'];
} }
} }
if (!isset($this->data['User']['authkey']) || empty($this->data['User']['authkey'])) $this->generateAuthKey(); if (!isset($this->data['User']['authkey']) || empty($this->data['User']['authkey'])) $this->data['User']['authkey'] = $this->generateAuthKey();
if (!isset($this->data['User']['nids_sid']) || empty($this->data['User']['nids_sid'])) $this->data['User']['nids_sid'] = mt_rand(1000000, 9999999); if (!isset($this->data['User']['nids_sid']) || empty($this->data['User']['nids_sid'])) $this->data['User']['nids_sid'] = mt_rand(1000000, 9999999);
return true; return true;
} }