bestmomo / laravel5-3-example

Simple laravel 5-3 example for tutorial
224 stars 114 forks source link

About `resend()` method in `RegisterController.php` #16

Closed zwl1619 closed 7 years ago

zwl1619 commented 7 years ago

There is a resend() method in \app\Http\Controllers\Auth\RegisterController.php:

    public function resend(UserRepository $userRepository, Request $request)
    {
        if ($request->session()->has('user_id')) {
            $user = $userRepository->getById($request->session()->get('user_id'));

            $this->notifyUser($user);

            return redirect('/')->with('ok', trans('front/verify.resend'));
        }

        return redirect('/');
    }

I don't understand $request->session()->has('user_id') . When is there user_id in session and when is there no user_id in session?

bestmomo commented 7 years ago

Hi, If you look at login method in LoginController you'll see where this session value is created. It's when a user want to login but is not confirmed, so the id is stocked in session and there is a redirection on login page with a special message and a button to resend url. We need id to notify the user.

zwl1619 commented 7 years ago

@bestmomo thanks! I see.