Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace Lieng\Http\Controllers\Auth;
- use Illuminate\Http\Request;
- use Illuminate\Mail\Message;
- use Lieng\Http\Controllers\Controller;
- use Illuminate\Support\Facades\Password;
- use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
- class ForgotPasswordController extends Controller
- {
- /*
- |--------------------------------------------------------------------------
- | Password Reset Controller
- |--------------------------------------------------------------------------
- |
- | This controller is responsible for handling password reset requests
- | and uses a simple trait to include this behavior. You're free to
- | explore this trait and override any methods you wish to tweak.
- |
- */
- use SendsPasswordResetEmails;
- protected $redirectTo = '/';
- /**
- * Create a new password controller instance.
- */
- public function __construct()
- {
- $this->middleware('guest');
- }
- public function sendResetLinkEmail(Request $request)
- {
- $this->validate($request, ['email' => 'required|email|exists:users']);
- $response = Password::sendResetLink($request->only('email'), function (Message $message) {
- $message->subject(trans('mail.password_recovery'));
- });
- switch ($response) {
- case Password::RESET_LINK_SENT:
- if ($request->isJson()) {
- return ['success' => true];
- }
- return redirect()->back()->with('status', trans($response));
- case Password::INVALID_USER:
- return redirect()->back()->withErrors(['email' => trans($response)]);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement