本文整理汇总了PHP中Password::broker方法的典型用法代码示例。如果您正苦于以下问题:PHP Password::broker方法的具体用法?PHP Password::broker怎么用?PHP Password::broker使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Password
的用法示例。
在下文中一共展示了Password::broker方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sendResetLinkEmail
public function sendResetLinkEmail(Request $request)
{
$this->validate($request, ['email' => 'required|email']);
$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);
}
}
示例2: postReset
/**
* Handle a POST request to reset a user's password.
*
* @return \Illuminate\Routing\Redirector|\Illuminate\Http\RedirectResponse
*/
public function postReset(Request $request)
{
$form = FormBuilder::create('Distilleries\\Expendable\\Forms\\Login\\Forgotten');
if ($form->hasError()) {
return $form->validateAndRedirectBack();
}
$credentials = $request->only('email', 'password', 'password_confirmation', 'token');
$broker = $this->getBroker();
$response = \Password::broker($broker)->reset($credentials, function ($user, $password) {
$user->password = bcrypt($password);
$user->save();
if (method_exists($user, 'unlock')) {
$user->unlock();
}
$this->auth->login($user);
});
switch ($response) {
case \Password::INVALID_PASSWORD:
case \Password::INVALID_TOKEN:
case \Password::INVALID_USER:
return redirect()->back()->with('error', trans($response));
case \Password::PASSWORD_RESET:
return redirect()->to(action('\\' . get_class($this) . '@getIndex'));
}
}
示例3: postEmail
/**
* 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|exists:' . zbase_config_get('entity.user.table.name') . ',email']);
$entity = zbase()->entity('user', [], true);
$user = $entity->repo()->by('email', zbase_request_input('email'))->first();
if (!empty($user)) {
$broker = $this->getBroker();
$response = \Password::broker($broker)->sendResetLink($this->getSendResetLinkEmailCredentials($request), $this->resetEmailBuilder());
$user->lostPassword();
}
zbase()->json()->setVariable('password_success', 1);
zbase()->json()->setVariable('_redirect', zbase_url_previous());
if (!zbase_is_json()) {
return redirect()->back()->with('status', trans(\Password::RESET_LINK_SENT));
}
}