コード例 #1
0
ファイル: Captcha.php プロジェクト: mgh145/captcha
 /**
  * Generate captcha text
  *
  * @return string
  */
 protected function generate()
 {
     $characters = str_split($this->characters);
     $bag = '';
     for ($i = 0; $i < $this->length; $i++) {
         $bag .= $characters[rand(0, count($characters) - 1)];
     }
     $this->session->put('captcha', ['sensitive' => $this->sensitive, 'key' => $this->hasher->make($this->sensitive ? $bag : $this->str->lower($bag))]);
     return $bag;
 }
コード例 #2
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');
 }
コード例 #3
0
ファイル: Captcha.php プロジェクト: votong/captcha
 /**
  *
  * @return string
  */
 protected function generate()
 {
     $characters = str_split($this->characters);
     $bag = '';
     for ($i = 0; $i < $this->length; $i++) {
         $bag .= $characters[rand(0, count($characters) - 1)];
     }
     if (!$this->sensitive) {
         $bag = $this->str->lower($bag);
     }
     if ($this->formId) {
         //Log::info('$this->formId: ' . $this->formId . ' = ' . $bag);
         $this->session->put('captcha_' . $this->formId, $this->hasher->make($bag));
         //Log::info('$this->formId: ' . $this->formId . ' = ' . $this->session->get('captcha_' . $this->formId));
     } else {
         $this->session->put('captcha', $this->hasher->make($bag));
     }
     return $bag;
 }
コード例 #4
0
ファイル: _ide_helper.php プロジェクト: satriashp/tour
 /**
  * Hash the given value.
  *
  * @param string $value
  * @param array $options
  * @return string 
  * @throws \RuntimeException
  * @static 
  */
 public static function make($value, $options = array())
 {
     return \Illuminate\Hashing\BcryptHasher::make($value, $options);
 }
コード例 #5
0
ファイル: Vocal.php プロジェクト: lakedawson/vocal
 /**
  * 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);
         }
     }
 }
コード例 #6
0
 /**
  * Create a new HashedPassword
  *
  * @param Password $password
  * @return HashedPassword
  */
 public function hash(Password $password)
 {
     return new HashedPassword($this->hasher->make($password->toString()));
 }
コード例 #7
0
 /**
  * Create a new HashedPassword
  *
  * @param Password $password
  * @return HashedPassword
  */
 public function hash(Password $password)
 {
     return new HashedPassword($this->hasher->make((string) $password));
 }
コード例 #8
0
 public function getAuthPassword()
 {
     $hasher = new BcryptHasher();
     return $hasher->make($this->password);
 }
コード例 #9
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));
 }
コード例 #10
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')]);
 }