Advertisement
Guest User

Untitled

a guest
May 4th, 2016
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.80 KB | None | 0 0
  1. class PasswordController extends Controller
  2. {
  3.     /*
  4.     |--------------------------------------------------------------------------
  5.     | Password Reset Controller
  6.     |--------------------------------------------------------------------------
  7.     |
  8.     | This controller is responsible for handling password reset requests
  9.     | and uses a simple trait to include this behavior. You're free to
  10.     | explore this trait and override any methods you wish to tweak.
  11.     |
  12.     */
  13.  
  14.     public $redirectPath = '/';
  15.  
  16.     use ResetsPasswords, CanResetPassword;
  17.  
  18.     /**
  19.      * Create a new password controller instance.
  20.      *
  21.      * @return void
  22.      */
  23.     public function __construct()
  24.     {
  25.         $this->middleware('guest');
  26.     }
  27.  
  28.  
  29.     public function sendResetLink(array $credentials)
  30.     {
  31.  
  32.         $user = Password::getUser($credentials);
  33.  
  34.         if (is_null($user)) {
  35.             return Password::INVALID_USER;
  36.         }
  37.  
  38.         $token = Password::getRepository()->create($user);
  39.  
  40.         $lembrio = new LembrioClient();
  41.         $lembrio->recuperarSenha($user, $token);
  42.  
  43.         return Password::RESET_LINK_SENT;
  44.     }
  45.  
  46.  
  47.     public function sendResetLinkEmail(Request $request)
  48.     {
  49.         $this->validate($request, ['email' => 'required|email']);
  50.  
  51.         $response = $this->sendResetLink($request->only('email'));
  52.  
  53.         switch ($response) {
  54.             case Password::RESET_LINK_SENT:
  55.                 return $this->getSendResetLinkEmailSuccessResponse($response);
  56.  
  57.             case Password::INVALID_USER:
  58.             default:
  59.                 return $this->getSendResetLinkEmailFailureResponse($response);
  60.         }
  61.     }
  62.  
  63.     protected function resetPassword($user, $password)
  64.     {
  65.         $user->password = bcrypt($password);
  66.  
  67.         $user->save();
  68.     }
  69.  
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement