本文整理汇总了PHP中Illuminate\Support\Facades\Password::broker方法的典型用法代码示例。如果您正苦于以下问题:PHP Password::broker方法的具体用法?PHP Password::broker怎么用?PHP Password::broker使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Support\Facades\Password
的用法示例。
在下文中一共展示了Password::broker方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sendResetLinkEmail
public function sendResetLinkEmail(Request $request)
{
$this->validate($request, ['user_email' => 'required|email']);
$broker = $this->getBroker();
$response = Password::broker($broker)->sendResetLink($request->only('user_email'), function (Message $message) {
$message->subject($this->getEmailSubject());
});
switch ($response) {
case Password::RESET_LINK_SENT:
return $this->getSendResetLinkEmailSuccessResponse($response);
case Password::INVALID_USER:
default:
return $this->getSendResetLinkEmailFailureResponse($response);
}
}
示例2: subscribe
public function subscribe(Dispatcher $events)
{
$events->listen(FrontUserRegistered::class, function (FrontUserRegistered $event) {
Mail::send(new Welcome($event->user));
});
$events->listen(FrontUserCreatedThroughBack::class, function (FrontUserCreatedThroughBack $event) {
Password::broker('front')->sendResetLink(['email' => $event->user->email], function (Message $message) {
$message->subject('Welkom bij ' . config('app.url'));
});
});
$events->listen(BackUserCreated::class, function (BackUserCreated $event) {
Password::broker('back')->sendResetLink(['email' => $event->user->email], function (Message $message) {
$message->subject('Welkom bij ' . config('app.url'));
});
});
}
示例3: reset
/**
* [reset description]
* @param [type] $request [description]
* @return [type] [description]
*/
public function reset($request, $broker, $guard)
{
$this->validate($request, $this->getResetValidationRules());
$credentials = $request->only('email', 'password', 'password_confirmation', 'token');
$response = IlluminatePassword::broker($broker)->reset($credentials, function ($user, $password) use($guard) {
$this->resetPassword($user, $password, $guard);
});
switch ($response) {
case IlluminatePassword::PASSWORD_RESET:
return $this->getResetSuccessResponse($response);
break;
default:
return $this->getResetFailureResponse($request, $response);
break;
}
}
示例4: reset
/**
* Reset the given user's password.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function reset(Request $request)
{
$this->validate($request, $this->getResetValidationRules());
$credentials = $request->only('email', 'password', 'password_confirmation', 'token');
$broker = $this->getBroker();
$response = Password::broker($broker)->reset($credentials, function ($user, $password) {
$this->resetPassword($user, $password);
});
switch ($response) {
case Password::PASSWORD_RESET:
return redirect()->route('reset.success')->withSuccess(trans($response));
//return $this->getResetSuccessResponse($response);
//return $this->getResetSuccessResponse($response);
default:
return $this->getResetFailureResponse($request, $response);
}
}
示例5: sendResetLinkEmail
/**
* Send a reset link to the given user.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function sendResetLinkEmail(Request $request)
{
$this->validate($request, ['email' => 'required|email']);
if (User::where('email', $request->only('email'))->where('password', '!=', '')->count() != 1) {
return $this->getSendResetLinkEmailFailureResponse('Akun tidak ditemukan');
}
$broker = $this->getBroker();
$response = Password::broker($broker)->sendResetLink($request->only('email'), function (Message $message) {
$message->subject($this->getEmailSubject());
});
switch ($response) {
case Password::RESET_LINK_SENT:
return $this->getSendResetLinkEmailSuccessResponse($response);
case Password::INVALID_USER:
default:
return $this->getSendResetLinkEmailFailureResponse($response);
}
}
示例6: sendResetLinkEmail
/**
* Send a reset link to the given user.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function sendResetLinkEmail(Request $request)
{
$rules = ['email' => 'required|email'];
if (config('inoplate.account.enable_captcha')) {
$captchaDriver = config('captcha.challenge');
$rules[config('captcha.drivers.' . $captchaDriver . '.input')] = 'required|captcha';
}
$this->validate($request, $rules);
$broker = $this->getBroker();
$response = Password::broker($broker)->sendResetLink($request->only('email'), function (Message $message) {
$message->subject($this->getEmailSubject());
});
switch ($response) {
case Password::RESET_LINK_SENT:
return $this->getSendResetLinkEmailSuccessResponse($response);
case Password::INVALID_USER:
default:
return $this->getSendResetLinkEmailFailureResponse($response);
}
}
示例7: reset
public function reset(Request $request)
{
$inputData = Input::all();
$rules = array('token' => 'required', 'email' => 'required|email', 'password' => 'required|confirmed|min:6');
$validator = Validator::make($inputData, $rules);
if ($validator->fails()) {
return Response::json(['success' => false, 'errors' => $validator->getMessageBag()->toArray()]);
} else {
$credentials = $request->only('email', 'password', 'password_confirmation', 'token');
$broker = $this->getBroker();
$response = Password::broker($broker)->reset($credentials, function ($user, $password) {
$this->resetPassword($user, $password);
});
switch ($response) {
case Password::PASSWORD_RESET:
$this->getResetSuccessResponse($response);
return Response::json(['success' => true, 'message' => '成功更改密碼!']);
default:
$this->getResetFailureResponse($request, $response);
return Response::json(['success' => false, 'errors' => '異常錯誤, 請更新頁面再重試!']);
}
}
}
示例8: sendResetLinkEmail
/**
* Send a reset link to the user.
*
* @param Request $request
* @return \Illuminate\Http\Response
*/
public function sendResetLinkEmail(Request $request)
{
/*
* --------------------------------------------------------------------------
* Send reset email
* --------------------------------------------------------------------------
* Validate input email, check if email has been registered before, get
* default broker to find out email file location and finally send the
* reset email to user.
*/
$this->validate($request, ['email' => 'required|email']);
$broker = $this->getBroker();
$response = Password::broker($broker)->sendResetLink($request->only('email'), function (Message $message) {
$message->subject($this->getEmailSubject());
$message->replyTo('no-reply@infogue.id', env('MAIL_NAME', 'Infogue.id'));
});
switch ($response) {
case Password::RESET_LINK_SENT:
return $this->getSendResetLinkEmailSuccessResponse($response);
case Password::INVALID_USER:
default:
return $this->getSendResetLinkEmailFailureResponse($response);
}
}
示例9: broker
/**
* Get the broker to be used during password reset.
*
* @return \Illuminate\Support\Facades\Password
*/
public function broker()
{
return Password::broker('pulsarPasswordBroker');
}
示例10: broker
/**
* Get the broker to be used during password reset.
*
* @return \Illuminate\Contracts\Auth\PasswordBroker
*/
public function broker()
{
return Password::broker();
}
示例11: reset
public function reset(Request $request)
{
$this->validate($request, array('token' => 'required', 'email' => 'required|email', 'password' => 'required|confirmed|min:6'));
$credentials = $request->only('email', 'password', 'password_confirmation', 'token');
$broker = $this->getBroker();
$response = Password::broker($broker)->reset($credentials, function ($user, $password) {
$this->resetPassword($user, $password);
});
switch ($response) {
case Password::PASSWORD_RESET:
return $this->getResetSuccessResponse($response);
default:
return $this->getResetFailureResponse($request, $response);
}
}
示例12: getPasswordBroker
/**
* Get the broker to be used during password reset.
*
* @return \Illuminate\Contracts\Auth\PasswordBroker
*/
private function getPasswordBroker()
{
return Password::broker();
}
示例13: proceedResetPassword
/**
* Handle showing form and update password
*
* @param \Illuminate\Http\Request $request
* @param string $email
* @param string $token
* @return \Illuminate\Http\Response
*/
public function proceedResetPassword(Request $request, $email = null, $token = null)
{
if (is_null($token)) {
redirect(route('auth.reset_password.request'));
}
$resetForm = $this->createForm(PasswordResetUpdateType::class, array('email' => $email, 'token' => $token), array('action' => route('auth.reset_password.update_check')));
$resetForm->handleRequest($request);
if ($request->isMethod('post')) {
if ($resetForm->isValid()) {
$data = $resetForm->getData();
$credentials = array('email' => $data['email'], 'password_confirmation' => $data['plainPassword'], 'password' => $data['plainPassword'], 'token' => $data['token']);
$broker = $this->getBroker();
// Disable default password validator
Password::broker($broker)->validator(function () {
return true;
});
$response = Password::broker($broker)->reset($credentials, function ($user, $password) {
$this->resetPassword($user, $password);
});
switch ($response) {
case Password::PASSWORD_RESET:
return redirect($this->redirectPath())->with('status', trans('auth.message.reset_password.success'));
case Password::INVALID_USER:
return redirect($this->redirectPath())->with('status', trans('auth.message.reset_password.invalid_email'));
case Password::INVALID_TOKEN:
return redirect($this->redirectPath())->with('status', trans('auth.message.reset_password.invalid_token'));
default:
return redirect()->back()->with('status', trans('auth.message.reset_password.fail'));
}
}
}
if (property_exists($this, 'resetView')) {
return view($this->resetView, ['form' => $resetForm->createView()]);
}
if (view()->exists('auth.passwords.reset')) {
return view('auth.passwords.reset', ['form' => $resetForm->createView()]);
}
return view('auth.reset', ['form' => $resetForm->createView()]);
}
示例14: broker
/**
* Get the broker to be used during password reset.
*
* @return \Illuminate\Contracts\Auth\PasswordBroker
*/
public function broker()
{
return Password::broker('adminusers');
}
示例15: reset
/**
* Reset the given user's password.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function reset(Request $request)
{
$this->validate($request, $this->getResetValidationRules(), $this->getResetValidationMessages(), $this->getResetValidationCustomAttributes());
$credentials = $this->getResetCredentials($request);
$broker = $this->getBroker();
$response = Password::broker($broker)->reset($credentials, function ($user, $password) {
$this->resetPassword($user, $password);
});
switch ($response) {
case Password::PASSWORD_RESET:
return $this->getResetSuccessResponse($response);
default:
return $this->getResetFailureResponse($request, $response);
}
}