broker() public static method

Attempt to get the broker from the local cache.
public static broker ( string $name = null ) : Illuminate\Contracts\Auth\PasswordBroker
$name string
return Illuminate\Contracts\Auth\PasswordBroker
 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);
     }
 }
Exemplo n.º 2
0
 /**
  * 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'));
     }
 }
Exemplo n.º 3
0
 /**
  * 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));
     }
 }