Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SSR and MustVerifyEmail issue #137

Open
rudolfbruder opened this issue Jan 1, 2021 · 0 comments
Open

SSR and MustVerifyEmail issue #137

rudolfbruder opened this issue Jan 1, 2021 · 0 comments

Comments

@rudolfbruder
Copy link

Hi there,

First of all thanks for this great boilerplate. I am using it a lot. I found an issue when if you want to use SSR out of box without building the SPA version of your project your api path is inaccessible and it is throwing the file_get_contents error. This for me is not an issue because the api on subdomain works and if you provide a token you can use all the api endpoints where authorization is required.

However problem out of box is that the links in the notification which is send to user once they are registered (if MustVerify is enabled) contains link to the API back end end point.

There is a file called VerifyEmail.php and i modified the code a bit so that the link is actually sending end users to the front-end. ENV variables and config file needs to be setup.

    protected function verificationUrl($notifiable)
    {
        $url = URL::temporarySignedRoute(
            'verification.verify',
            Carbon::now()->addMinutes(60),
            ['user' => $notifiable->id]
        );

        info($url);
        return str_replace(config('app.api_url'), config('app.client_url'), $url);
        // return str_replace('/api', '', $url);
    }

My .env variables:
APP_URL=http://localhost:3000 API_URL=http://localhost:800

My app.php file config for this includes these lines

'url' => env('APP_URL', 'http://localhost:3000'), 'api_url' => env('API_URL', 'http://localhost'),

Also i found out that these lines in file EventServiceProvider.php

protected $listen = [ Registered::class => [ SendEmailVerificationNotification::class, ], ];

Are causing duplicate verification email generation because this email generation is also called in RegisterController.php file

    protected function registered(Request $request, User $user)
    {
        if ($user instanceof MustVerifyEmail) {
            $user->sendEmailVerificationNotification();

            return response()->json(['status' => trans('verification.sent')]);
        }
        return response()->json($user);
    }

What do you think about it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant