Esempio n. 1
0
 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;
 }
Esempio n. 2
0
 public function setPasswordAttribute($value)
 {
     if (!$value) {
         return;
     }
     $this->attributes['password'] = \Hash::make($value);
 }
Esempio n. 3
0
 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);
         }
     }
 }
Esempio 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;
     }
 }
Esempio n. 5
0
 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);
     }
 }
Esempio n. 6
0
 /**
  * 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;
 }
Esempio n. 7
0
 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'));
     }
 }
Esempio n. 8
0
 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;
 }
Esempio n. 9
0
 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;
 }
Esempio n. 10
0
 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;
             }
         }
     }
 }
Esempio n. 11
0
 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']);
 }
Esempio n. 12
0
 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.']);
 }
Esempio n. 13
0
 /**
  * [setPasswordAttribute Password Setter Mutator].
  *
  * @param [string] $value [Enforce Bcrypt On Save]
  */
 public function setPasswordAttribute($value)
 {
     if (!empty($value)) {
         $this->attributes['password'] = \Hash::make($value);
     }
 }
Esempio n. 14
0
 /**
  * 密码加密
  */
 public function setPasswordAttribute($password)
 {
     $this->attributes['password'] = \Hash::make($password);
 }
Esempio n. 15
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     User::create(['name' => 'Stef van den Berg', 'email' => '*****@*****.**', 'password' => Hash::make('test')]);
 }
Esempio n. 16
0
 public function setDelete($valor)
 {
     if (!empty($valor)) {
         $this->attributes['active'] = \Hash::make($valor);
     }
 }
Esempio n. 17
0
 public function setpasswordAttribute($value)
 {
     $this->attributes['password'] = \Hash::make($value);
 }
Esempio n. 18
0
 public function signup()
 {
     $this->password = \Hash::make($this->password);
     return $this->save();
 }
Esempio n. 19
0
 public function setPasswordAttribute($password)
 {
     $this->attributes['password'] = \Hash::make($password);
     //$password = bcrypt('secret');
     //$password = Hash::make('secret');
 }
Esempio n. 20
0
 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)]);
 }
Esempio n. 21
0
 public function setPasswordAttribute($passowrd)
 {
     $this->attributes['password'] = Hash::make($passowrd);
     //仅仅是举例
 }