php Illuminate-Support-Facades-Password类(方法)实例源码

下面列出了php Illuminate-Support-Facades-Password 类(方法)源码代码实例,从而了解它的用法。

作者:NickMomche    项目:bautec   
public function postReset(Request $request)
 {
     $params = $request->only('email', 'password', 'password_confirmation', 'token');
     $filter = $this->validator($params);
     if ($filter->fails()) {
         //            return $this->responseAnswer(true, NULL, trans('rest.14'), 14, $filter->errors());
         return view('admin.reset')->with(['token' => $params['token'], 'message' => trans('auth.failed'), 'email' => $params['email'], 'error' => $filter->errors()->toArray()]);
     }
     $response = Password::reset($params, function ($user, $password) {
         $this->resetPassword($user, $password);
     });
     switch ($response) {
         case Password::PASSWORD_RESET:
             //                $this->data = [
             //                            'authenticated' => true,
             //                            'role' => Auth::user()->isAdmin ? 'admin' : 'user',
             //                        ];
             //                return $this->responseAnswer(false, $this->data, trans($response));
             return redirect('/');
         default:
             //                $this->data = [
             //                            'email' => $params['email'],
             //                            'token' => $params['token'],
             //                            'authenticated' => false,
             //                            'role' => 'guest',
             //                        ];
             //                return $this->responseAnswer(true, NULL, trans($response), 1);
             return view('admin.reset')->with(['token' => $params['token'], 'message' => $response, 'email' => $params['email']]);
     }
 }

作者:johanW    项目:pandor   
/**
  * Send a reset link to the given user.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function postEmail(Request $request)
 {
     //        $this->validate($request, ['email' => 'required|email', 'username' =>'required']);
     /*
             $response = Password::sendResetLink($request->only('email'), function (Message $message) {
                 $message->subject($this->getEmailSubject());
             });
     */
     $this->validate($request, ['email' => 'required|email', 'username' => 'required']);
     $correo = DB::table('users')->where('username', '=', $request->username)->first();
     if (is_null($correo)) {
         $response = Password::INVALID_USER;
     } else {
         if ($correo->email == $request->email) {
             $response = Password::sendResetLink($request->only('email'), function (Message $message) {
                 $message->subject($this->getEmailSubject());
             });
         } else {
             $response = Password::INVALID_USER;
         }
     }
     switch ($response) {
         case Password::RESET_LINK_SENT:
             session()->flash('flash_message', 'Se ha enviado un correo a la dirección de correo asociada.');
             return view('auth.password');
         case Password::INVALID_USER:
             //session()->flash('flash_message_danger', 'No existe un usuario con ese nombre.');
             return redirect()->back()->withErrors(['email' => trans($response)]);
     }
 }

作者:binary    项目:terenuripedi   
/**
  * @param  Request                                   $request
  * @throws GeneralException
  * @return $this|\Illuminate\Http\RedirectResponse
  */
 public function postEmail(Request $request)
 {
     /**
      * First of all check if the input is a valid email
      */
     $this->validate($request, ['email' => 'required|email']);
     /**
      * Make sure user is confirmed before resetting password.
      */
     $user = User::where('email', $request->get('email'))->first();
     if ($user) {
         if ($user->confirmed == 0) {
             throw new GeneralException('Your account is not confirmed. Please click the confirmation link in your e-mail, or ' . '<a href="' . route('account.confirm.resend', $user->id) . '">click here</a>' . ' to resend the confirmation e-mail.');
         }
     } else {
         throw new GeneralException('There is no user with that e-mail address.');
     }
     $response = Password::sendResetLink($request->only('email'), function (Message $message) {
         $message->subject($this->getEmailSubject());
     });
     switch ($response) {
         case Password::RESET_LINK_SENT:
             return redirect()->back()->with('status', trans($response));
         case Password::INVALID_USER:
             return redirect()->back()->withErrors(['email' => trans($response)]);
     }
 }

作者:rizalafan    项目:Laravel-5.1-Multi-Auth-Exampl   
protected function reset_process($credentials)
 {
     return Password::user()->reset($credentials, function ($user, $password) {
         $user->password = bcrypt($password);
         $user->save();
         Auth::user()->login($user);
     });
 }

作者:sibasb    项目:siba   
/**
  * Send a reset link to the given user.
  *
  * @param  \Illuminate\Http\Request $request
  *
  * @return \Illuminate\Http\Response
  */
 public function postEmail(Request $request)
 {
     $this->validate($request, ['email' => 'required|email']);
     $response = Password::sendResetLink($request->only('email'), function (Message $message) {
         $message->subject($this->getEmailSubject());
     });
     switch ($response) {
         case Password::RESET_LINK_SENT:
             return redirect()->back()->with('status', 'Hemos enviando un link a tu cuenta de correo electrónico para que puedas resetear la contraseña');
         case Password::INVALID_USER:
             return redirect()->back()->withErrors(['email' => trans($response)]);
     }
 }

作者:RenzoCC    项目:base609427   
public function postEmail(Request $request)
 {
     $this->validate($request, ['email' => 'required|email|max:255']);
     $response = Password::sendResetLink($request->only('email'), function (Message $message) {
         $message->subject($this->getEmailSubject());
     });
     switch ($response) {
         case Password::RESET_LINK_SENT:
             return redirect()->back()->with('message', trans($response))->with('loginTab', 'login');
         case Password::INVALID_USER:
             return redirect()->back()->withErrors(['email' => trans($response)])->with('loginTab', 'password');
     }
 }

作者:cptsk    项目:laravel5-exampl   
/**
  * Reset the given user's password.
  * 
  * @param  ResetPasswordRequest  $request
  * @return Response
  */
 public function postReset(ResetPasswordRequest $request)
 {
     $credentials = $request->only('email', 'password', 'password_confirmation', 'token');
     $response = Password::reset($credentials, function ($user, $password) {
         $this->resetPassword($user, $password);
     });
     switch ($response) {
         case Password::PASSWORD_RESET:
             return redirect()->to('/')->with('ok', trans('passwords.reset'));
         default:
             return redirect()->back()->with('error', trans($response))->withInput($request->only('email'));
     }
 }

作者:absi    项目:EsmorzarsIBenzin   
/**
  * Reset the given user's password.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function postReset(Request $request)
 {
     $this->validate($request, ['token' => 'required', 'email' => 'required|email', 'password' => 'required|confirmed|min:6']);
     $credentials = $request->only('email', 'password', 'password_confirmation', 'token');
     $response = Password::reset($credentials, function ($user, $password) {
         $this->resetPassword($user, $password);
     });
     if ($response == Password::PASSWORD_RESET) {
         return response()->json(["msg" => "Success", "data" => true], 200);
     } else {
         return response()->json(["msg" => "Unknown error", "data" => $response], 400);
     }
 }

作者:farrukhc    项目:laravel-5-boilerplat   
/**
  * @param ResetPasswordRequest $request
  * @return $this|\Illuminate\Http\RedirectResponse
  */
 public function reset(ResetPasswordRequest $request)
 {
     $credentials = $request->only('email', 'password', 'password_confirmation', 'token');
     $response = Password::reset($credentials, function ($user, $password) {
         $this->resetPassword($user, $password);
     });
     switch ($response) {
         case Password::PASSWORD_RESET:
             return redirect($this->redirectPath())->with('status', trans($response));
         default:
             return redirect()->back()->withInput($request->only('email'))->withErrors(['email' => trans($response)]);
     }
 }

作者:franciscoBarriento    项目:larave   
public function postEmail(PasswordRequest $request)
 {
     $response = Password::sendResetLink($request->only('email'), function (Message $message) {
         $message->subject($this->getEmailSubject());
     });
     switch ($response) {
         case Password::RESET_LINK_SENT:
             Session::flash('message', 'Link de recuperación enviado por correo');
             return redirect()->back()->with('status', trans($response));
         case Password::INVALID_USER:
             return redirect()->back()->withErrors(['email' => trans($response)]);
     }
 }

作者:joselfonsec    项目:laravel-admin-res   
/**
  * Reset the given user's password.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function doReset(ResetPasswordRequest $request)
 {
     $credentials = $request->only('email', 'password', 'password_confirmation', 'token');
     $response = Password::reset($credentials, function ($user, $password) {
         $user->password = bcrypt($password);
         $user->save();
     });
     switch ($response) {
         case Password::PASSWORD_RESET:
             return $this->simpleArray(['message' => 'Se ha actualizado su contraseña.']);
         default:
             throw new ResourceException('No hemos podido restaurar su contraseña, verifique la información enviada.');
     }
 }

作者:Jemo    项目:ba_hostin   
/**
  * Send a reset link to the given user.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function postEmail(Request $request)
 {
     $this->validate($request, ['email' => 'required|email']);
     $response = Password::sendResetLink($request->only('email'), function (Message $message) {
         $message->subject($this->getEmailSubject());
     });
     switch ($response) {
         case Password::RESET_LINK_SENT:
             Session::flash('flash_message', 'Reset Link was successfully sent to your email');
             return redirect()->back()->with('status', trans($response));
         case Password::INVALID_USER:
             return redirect()->back()->withErrors(['email' => trans($response)]);
     }
 }

作者:patrikkernk    项目:basecamp-module   
/**
  * Reset the given user's password.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function postReset(Request $request)
 {
     $this->validate($request, ['token' => 'required', 'email' => 'required|email', 'password' => 'required|confirmed|min:6']);
     $credentials = $request->only('email', 'password', 'password_confirmation', 'token');
     $response = Password::reset($credentials, function ($user, $password) {
         $this->resetPassword($user, $password);
     });
     switch ($response) {
         case Password::PASSWORD_RESET:
             return redirect()->route('basecamp::login');
         default:
             abort(500, 'Invalid operation (User / Password / Token).');
     }
 }

作者:IzakRamma    项目:SmartAd   
/**
  * Send a reset link to the given user.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function postEmail(Request $request)
 {
     $this->validate($request, ['email' => 'required|email']);
     $response = Password::sendResetLink($request->only('email'), function (Message $message) {
         $message->from('smartads@domain.com', $name = 'Smart Ads');
         $message->subject($this->getEmailSubject());
     });
     switch ($response) {
         case Password::RESET_LINK_SENT:
             return redirect()->back()->with('status', trans($response));
         case Password::INVALID_USER:
             return redirect()->back()->withErrors(['email' => trans($response)]);
     }
 }

作者:kyxe    项目:barriosLarave   
/**
  * Reset the given user's password.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function postReset(Request $request)
 {
     $this->validate($request, ['token' => 'required', 'password' => 'required|confirmed|min:6|max:16']);
     $credentials = $request->only('password', 'password_confirmation', 'token');
     $response = Password::reset($credentials, function ($user, $password) {
         $this->resetPassword($user, $password);
     });
     switch ($response) {
         case Password::PASSWORD_RESET:
             return redirect()->back()->with('successReset', [1]);
         default:
             return redirect()->back()->withErrors(['token' => trans($response)]);
     }
 }

作者:darryldecod    项目:laravelbacken   
/**
  * Reset the given user's password.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function postReset(Request $request)
 {
     $this->validate($request, ['token' => 'required', 'email' => 'required|email', 'password' => 'required|confirmed']);
     $credentials = $request->only('email', 'password', 'password_confirmation', 'token');
     $response = Password::reset($credentials, function ($user, $password) {
         $this->resetPassword($user, $password);
     });
     switch ($response) {
         case Password::PASSWORD_RESET:
             return redirect(config('backend.backend.base_url') . '/dashboard');
         default:
             return redirect()->back()->withInput($request->only('email'))->withErrors(['email' => trans($response)]);
     }
 }

作者:thecse    项目:laravel-noredirect-trait   
/**
  * Reset the given user's password.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function postReset(Request $request)
 {
     $this->validate($request, ['token' => 'required', 'email' => 'required|email', 'password' => 'required|confirmed|min:6']);
     $credentials = $request->only('email', 'password', 'password_confirmation', 'token');
     $response = Password::reset($credentials, function ($user, $password) {
         $this->resetPassword($user, $password);
     });
     switch ($response) {
         case Password::PASSWORD_RESET:
             return new JsonResponse([], 200);
         default:
             return new JsonResponse(['error' => trans($response)], 422);
     }
 }

作者:Orv    项目:mlraamatt   
/**
  * Reset the given user's password.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function postReset(Request $request)
 {
     $this->validate($request, ['token' => 'required', 'email' => 'required|email', 'password' => 'required|min:8|confirmed'], ['email.required' => 'Sähköpostiosoite vaaditaan varmuuden vuoksi.', 'email.email' => 'Annettu sähköpostiosoite ei ole pätevä.', 'password.required' => 'Salasana puuttuu.', 'password.min' => 'Salasanan pitää olla vähintään :min merkkiä pitkä.', 'password.confirmed' => 'Salasanat eivät täsmää.']);
     $credentials = $request->only('email', 'password', 'password_confirmation', 'token');
     $response = Password::reset($credentials, function ($user, $password) {
         $this->resetPassword($user, $password);
     });
     switch ($response) {
         case Password::PASSWORD_RESET:
             return redirect($this->redirectPath())->with('status', trans($response));
         default:
             return redirect()->back()->withInput($request->only('email'))->withErrors(['email' => trans($response)]);
     }
 }

作者:Shoode    项目:Event   
/**
  * Reset the given user's password.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function reset(Request $request)
 {
     $this->validate($request, ['token' => 'required', 'email' => 'required|email', 'password' => 'required|confirmed|min:6']);
     $credentials = $request->only('email', 'password', 'password_confirmation', 'token');
     $response = Password::reset($credentials, function ($user, $password) {
         $this->resetPassword($user, $password);
     });
     switch ($response) {
         case Password::PASSWORD_RESET:
             return redirect('login')->with('status', trans($response))->with('success', 'Your password has been reset, you can now log in.');
         default:
             return redirect()->back()->withInput($request->only('email'))->withErrors(['email' => trans($response)])->with('error', 'An error has occured, please try again.');
     }
 }

作者:r3k    项目:ujianonlin   
public function postReset(Request $request)
 {
     $this->validate($request, ['token' => 'required', 'email' => 'required|email', 'password' => 'required|confirmed|min:6']);
     $credentials = $request->only('email', 'password', 'password_confirmation', 'token');
     $response = Password::reset($credentials, function ($user, $password) {
         $this->resetPassword($user, $password);
     });
     switch ($response) {
         case Password::PASSWORD_RESET:
             return redirect()->route('auth.password_reminder.getEmail')->with('status', trans($response));
         default:
             return redirect()->back()->withInput($request->only('email'))->withErrors(['email' => trans($response)]);
     }
 }


问题


面经


文章

微信
公众号

扫码关注公众号