Exemplo n.º 1
0
 /**
  * 密码调整器
  *
  * @param $password
  */
 public function setAdminPassAttribute($password)
 {
     if (Hash::needsRehash($password)) {
         $password = Hash::make($password);
     }
     $this->attributes['admin_pass'] = $password;
 }
Exemplo n.º 2
0
 function saving($model)
 {
     ///////////
     // RULES //
     ///////////
     $rules['name'] = ['required'];
     $rules['password'] = ['required', 'min:8'];
     $rules['gender'] = ['required', 'in:pria,wanita'];
     $rules['dob'] = ['date', 'date_format:Y-m-d'];
     $rules['email'] = ['email', 'unique:users,email,' . ($model->_id ? $model->_id : 'NULL') . ',_id'];
     $rules['phone'] = ['string'];
     //////////////
     // VALIDATE //
     //////////////
     $data = $model->toArray();
     $data['password'] = $model->password;
     $validator = Validator::make($data, $rules);
     if ($validator->fails()) {
         $model->setErrors($validator->messages());
         return false;
     }
     // Hash password
     if (Hash::needsRehash($data['password'])) {
         $model->password = Hash::make($data['password']);
     }
 }
Exemplo n.º 3
0
 /**
  * @param $user
  * Hashes the users password if the developer wasn't already hashing it via an other method
  * such as an attribute
  * @return bool
  */
 public function saving($user)
 {
     if (Hash::needsRehash($user->password)) {
         $user->password = Hash::make($user->password);
     }
     return true;
 }
Exemplo n.º 4
0
 /**
  * Hash the users password.
  *
  * @param $value
  */
 public function setPasswordAttribute($value)
 {
     if (Hash::needsRehash($value)) {
         $this->attributes['password'] = bcrypt($value);
     } else {
         $this->attributes['password'] = $value;
     }
 }
Exemplo n.º 5
0
Arquivo: User.php Projeto: lc0991/Todo
 public function setPasswordAttribute($password)
 {
     if (Hash::needsRehash($password)) {
         $this->attributes['password'] = Hash::make($password);
     } else {
         $this->attributes['password'] = $password;
     }
 }
Exemplo n.º 6
0
 /**
  * Check if the user's password needs rehashing.
  */
 public function rehashPassword($password)
 {
     if (!Hash::needsRehash($this->getAttributeFromArray('password'))) {
         return;
     }
     if (!$this->confirmPassword($password)) {
         return;
     }
     $this->setPasswordAttribute($password);
     return $this->save();
 }
Exemplo n.º 7
0
 /**
  * @return string
  */
 public function getLogicButtonAttribute()
 {
     // ajax route for creating new question
     $logicurl = route('ajax.project.question.addlogic', [$this->project->id, $this->id]);
     // get ajax urlhash for project
     $hash = $this->urlhash;
     if (isset($hash['logic'])) {
         $urlhash = $hash['logic'];
     } else {
         $urlhash = '';
     }
     // check if rehash need or not
     if (Hash::needsRehash($urlhash)) {
         // rehash if urlhash column in project table empty or invalid
         $hash['logic'] = Hash::make($logicurl);
         // update project table in database with new or correct urlhash
         $this->update(['urlhash' => $hash]);
     }
     $id = snake_case("{$this->qnum} -lgbtn");
     $dataid = snake_case("{$this->qnum} -btn");
     return '<a data-href="' . $logicurl . '" id=" ' . $id . '" data-modal="' . $dataid . '" href="#" class="btn btn-xs btn-primary ' . $dataid . '" data-toggle="modal" data-target="#logic" data-type="edit"><i class="fa fa-info" data-toggle="tooltip" data-placement="top" title="Add Logic"  ></i></a>';
 }
Exemplo n.º 8
0
 public function setPasswordAttribute($value)
 {
     if (strlen($value) < 3) {
         return;
     }
     $this->attributes['password'] = Hash::needsRehash($value) ? bcrypt($value) : $value;
 }