Exemplo n.º 1
0
 /**
  * Unlocks a batch by checking the specified
  * password against the batch password.
  *
  * @param BatchUnlockRequest $request
  *
  * @return bool
  */
 public function unlock(BatchUnlockRequest $request)
 {
     $hasher = new BcryptHasher();
     if ($hasher->check($request->input('password'), $this->password)) {
         // Store the UUID in the users session so they can have
         // access to it for as long as the session exists
         $request->session()->put($this->uuid, $this->uuid);
         return true;
     }
     return false;
 }
Exemplo n.º 2
0
 /**
  * @param $value
  * @return bool
  */
 public function check($value)
 {
     $store = $this->session->get('captcha');
     if ($this->sensitive) {
         $value = $this->str->lower($value);
         $store = $this->str->lower($store);
     }
     return $this->hasher->check($value, $store);
 }
Exemplo n.º 3
0
 public function updateSettings(Request $request, Hash $hash)
 {
     $user = $request->user();
     $rules = ['old_password' => 'required|min:8', 'password' => 'required|confirmed|min:8'];
     $validator = app('validation')->make($request->all(), $rules);
     if ($validator->fails()) {
         $request->session->add(['errors' => $validator->errors()->all()]);
         return app('twig')->render('user/settings.htm', ['oldInputs' => $request->all()]);
     }
     if (!$hash->check($request->input('old_password'), $user->password)) {
         $request->session->add(['errors' => ['Old password incorrect.']]);
         return app('twig')->render('user/settings.htm', ['oldInputs' => $request->all()]);
     }
     $user->password = $hash->make($request->input('old_password'));
     $user->save();
     $request->session->add(['success' => 'settings updated successfuly.']);
     return app('twig')->render('user/settings.htm');
 }
Exemplo n.º 4
0
 /**
  *
  * @param $value
  * @return bool
  */
 public function check($value)
 {
     $store = $this->session->get('captcha' . (Input::has('captcha_id') ? '_' . Input::get('captcha_id') : ''));
     if ($this->sensitive) {
         $value = $this->str->lower($value);
         $store = $this->str->lower($store);
     }
     return $this->hasher->check($value, $store);
 }
Exemplo n.º 5
0
 /**
  * Captcha check
  *
  * @param $value
  * @return bool
  */
 public function check($value)
 {
     if (!$this->session->has('captcha')) {
         return false;
     }
     $key = $this->session->get('captcha.key');
     if (!$this->session->get('captcha.sensitive')) {
         $value = $this->str->lower($value);
     }
     $this->session->remove('captcha');
     return $this->hasher->check($value, $key);
 }
Exemplo n.º 6
0
 /**
  * Set the default password work factor.
  *
  * @param int $rounds
  * @return $this 
  * @static 
  */
 public static function setRounds($rounds)
 {
     return \Illuminate\Hashing\BcryptHasher::setRounds($rounds);
 }
Exemplo n.º 7
0
 /**
  * Check if the given hash has been hashed using the given options.
  *
  * @param string $hashedValue
  * @param array $options
  * @return bool 
  * @static 
  */
 public static function needsRehash($hashedValue, $options = array())
 {
     return \Illuminate\Hashing\BcryptHasher::needsRehash($hashedValue, $options);
 }
Exemplo n.º 8
0
 /**
  * Checks the specified pin against the current password folder pin.
  *
  * @param string $pin
  *
  * @return bool
  */
 public function checkPin($pin)
 {
     $hasher = new BcryptHasher();
     return $hasher->check($pin, $this->pin);
 }
Exemplo n.º 9
0
 /**
  * Hash any hashable attributes
  *
  * @return null
  */
 private function hashHashable()
 {
     $hasher = new BcryptHasher();
     $filtered = array_filter($this->attributes);
     foreach ($filtered as $key => $value) {
         if (in_array($key, $this->hashable) && $value != $this->getOriginal($key)) {
             $this->attributes[$key] = $hasher->make($value);
         }
     }
 }
Exemplo n.º 10
0
 /**
  * Create a new HashedPassword
  *
  * @param Password $password
  * @return HashedPassword
  */
 public function hash(Password $password)
 {
     return new HashedPassword($this->hasher->make($password->toString()));
 }
Exemplo n.º 11
0
 /**
  * Check if password matches
  *
  * @param Password $password
  * @param HashedPassword $hashedPassword
  * @return boolean
  */
 public function check(Password $password, HashedPassword $hashedPassword)
 {
     return $this->hasher->check($password->toString(), $hashedPassword->toString());
 }
Exemplo n.º 12
0
 /**
  * Create a new HashedPassword
  *
  * @param Password $password
  * @return HashedPassword
  */
 public function hash(Password $password)
 {
     return new HashedPassword($this->hasher->make((string) $password));
 }
Exemplo n.º 13
0
 public function getAuthPassword()
 {
     $hasher = new BcryptHasher();
     return $hasher->make($this->password);
 }
Exemplo n.º 14
0
 public function changePassword()
 {
     $adminId = Input::get("adminId");
     $username = Input::get("username");
     $oldPassword = Input::get("oldPassword");
     $newPassword = Input::get("newPassword");
     $newPasswordConfirm = Input::get("newPasswordConfirm");
     $hasher = new BcryptHasher();
     if (Auth::attempt(array('username' => $username, 'password' => $oldPassword))) {
         $result = Admin::where("admin_id", "=", $adminId)->update(["password" => $hasher->make($newPassword)]);
         if ($result == 0) {
             return Response::json(array('errCode' => 1, 'errMsg' => "[修改失败]数据库错误"));
         }
     } else {
         return Response::json(array('errCode' => 1, 'errMsg' => "[修改失败]原密码错误"));
     }
     return Response::json(array('errCode' => 0));
 }
 /**
  * Validate a user against the given credentials.
  *
  * @param  \Illuminate\Auth\Authenticatable $user
  * @param  array $credentials
  * @return bool
  */
 public function validateCredentials(Authenticatable $user, array $credentials)
 {
     return $credentials['type'] === 'shibboleth' ? true : $this->hasher->check($credentials['password'], $user->getAuthPassword());
 }
Exemplo n.º 16
0
 /**
  * @param Request      $request
  * @param BcryptHasher $hasher
  *
  * @return \Illuminate\Http\RedirectResponse
  */
 public function postPassword(Request $request, BcryptHasher $hasher)
 {
     $this->failedValidationRedirect = route('account.password');
     $this->validate($request, ['password1' => 'required|min:6', 'password' => 'required']);
     if ($this->guard->getProvider()->validateCredentials($this->guard->user(), $request->only('password'))) {
         // Don't save the password in plaintext!
         ConfirmationManager::send('password', $this->guard->user(), 'account.password.confirm', $hasher->make($request->get('password1')));
         return redirect()->route('account.profile')->withSuccess(trans('account.confirm'));
     }
     return redirect()->route('account.password')->withInput($request->only('password1'))->withErrors(['password1' => trans('member.invalidCredentials')]);
 }