public function verify($username, $password) { $credentials = ['username' => $username, 'password' => $password]; $person = new Person(); $resp = $person->getUsername($credentials['username']); if (!empty($resp)) { if (\Hash::check($credentials['password'], $resp['password'])) { $auth = true; } else { //check for old hashing if (md5($credentials['password']) == $resp['password']) { //convert old pass to new hashing $resp['password'] = bcrypt($credentials['password']); $id = my_encode($resp['id']); $person->update($id, $resp); $auth = true; } else { $auth = false; } } } else { //invalid user $auth = false; } if ($auth) { $result = $person->respondWithItem($resp, new UserTransformer()); session()->put('user', $result); return my_decode($resp['id']); } return false; }
public function setPasswordAttribute($value) { if (!$value) { return; } $this->attributes['password'] = \Hash::make($value); }
public function store(array $data) { $validator = Validator::make($data, $this->getValidationRules()); if ($validator->fails()) { $this->validation_errors = $validator->messages(); throw new \Exception("Invalid user input"); } else { //Do we have a password reset? if (isset($data['password']) && $data['password']) { $pass_validator = Validator::make($data, array('password' => 'confirmed')); if ($pass_validator->fails()) { $this->validation_errors = $pass_validator->messages(); throw new \Exception("Password and confirmation don't match"); } } //Fill user with the new data $this->name = trim($data['name']); $this->email = trim($data['email']); if (isset($data['password']) && $data['password']) { $this->password = \Hash::make(trim($data['password'])); } $this->save(); //Handle roles foreach ($this->roles as $role) { $this->detachRole($role); } foreach ($data['role_id'] as $role_id) { $this->attachRole($role_id); } } }
/** * Hash the users password * * @param $value */ public function setPasswordAttribute($value) { if (\Hash::needsRehash($value)) { $this->attributes['password'] = bcrypt($value); } else { $this->attributes['password'] = $value; } }
public function setPassword($valor) { //se o valor nao for vazio if (!empty($valor)) { //cria senha criptografada para o valor $this->attributes['password'] = \Hash::make($valor); } }
/** * Verify user credentials and authorize if everything fine. */ public function attempt($credentials, $field = 'email') { $model = new User(); $user = $model->where($field, '=', [$credentials[$field]])->first(); if ($user) { if (Hash::verify($credentials['password'], $user->password)) { $this->login($user); } } return false; }
public function setPasswordAttribute($value) { if (!\Request::has('password')) { if ($value) { $this->attributes['password'] = $value; } else { $this->attributes['password'] = $this->password; } } else { $this->attributes['password'] = \Hash::make(\Request::get('password')); } }
public function patch($data) { if (!empty($data['password'])) { $data['password'] = \Hash::make($data['password']); } else { unset($data['password']); } $this->fill($data); $this->save(); if (isset($data['updateRoles']) && $data['updateRoles']) { $this->clearAndUpdateRoles($data); } return $this; }
public function updateUser($id) { $user = User::find($id); if (is_null($user)) { return false; } $input = Input::all(); if (isset($input['password'])) { $input['password'] = Hash::make($input['password']); } $user->fill($input); $user->save(); return $user; }
protected function checkUser($email, $password) { $customer = Customer::where('email', '=', $email)->get(); if (count($customer) == 0) { return false; } else { foreach ($customer as $key => $value) { if (\Hash::check($password, $value['password'])) { \Session::put('name', $value['name']); \Session::put('email', $value['email']); \Session::put('role', $value['role']); return true; } else { return false; } } } }
public function registration() { $data = $this->request->inputs; $validator = $this->validate($data, ['email' => 'max:70|email|unique:users', 'password' => 'min:6|max:255|required', 'name' => 'max:255|required', 'photo' => 'image']); if ($validator->fail) { return app()->redirect('/'); } $tmp_name = $this->request->files['photo']['tmp_name']; $uploads_dir = public_path() . 'photos/'; $filename = md5($data['email']) . '.' . pathinfo($this->request->files['photo']['name'], PATHINFO_EXTENSION); if (!file_exists($uploads_dir)) { mkdir($uploads_dir, 0755, true); } move_uploaded_file($tmp_name, $uploads_dir . $filename); $credentials = ['email' => $data['email'], 'password' => Hash::make($data['password']), 'photo' => '/photos/' . $filename, 'name' => $data['name']]; $this->user->create($credentials); $this->auth->login($this->user); return app()->redirect('/users/' . $this->user->id, app()->messages['welcome']); }
public static function changePassword($user_id, $curr_pwd, $new_pwd) { $user = User::find($user_id); if (!isset($user)) { return Redirect::to('/crm/profile')->withMessage(['title' => 'Failed', 'body' => 'User Not Exist']); } if (Hash::check($curr_pwd, $user->password)) { // The passwords match, then now change pass to the new password. $user->password = Hash::make($new_pwd); $user->save(); return Redirect::to('/crm/profile')->withMessage(['title' => 'Success', 'body' => 'Password Change successfully.']); } return Redirect::to('/crm/profile')->withMessage(['title' => 'Failed', 'body' => 'Password Mismatch.']); }
/** * [setPasswordAttribute Password Setter Mutator]. * * @param [string] $value [Enforce Bcrypt On Save] */ public function setPasswordAttribute($value) { if (!empty($value)) { $this->attributes['password'] = \Hash::make($value); } }
/** * 密码加密 */ public function setPasswordAttribute($password) { $this->attributes['password'] = \Hash::make($password); }
/** * Run the database seeds. * * @return void */ public function run() { User::create(['name' => 'Stef van den Berg', 'email' => '*****@*****.**', 'password' => Hash::make('test')]); }
public function setDelete($valor) { if (!empty($valor)) { $this->attributes['active'] = \Hash::make($valor); } }
public function setpasswordAttribute($value) { $this->attributes['password'] = \Hash::make($value); }
public function signup() { $this->password = \Hash::make($this->password); return $this->save(); }
public function setPasswordAttribute($password) { $this->attributes['password'] = \Hash::make($password); //$password = bcrypt('secret'); //$password = Hash::make('secret'); }
public function createUser($firstName, $lastName, $email, $avatar_url, $password) { return User::create(["firstName" => $firstName, "lastName" => $lastName, "avatar" => $avatar_url, "email" => $email, "password" => \Hash::make($password)]); }
public function setPasswordAttribute($passowrd) { $this->attributes['password'] = Hash::make($passowrd); //仅仅是举例 }