#How to override the verification email link

8 messages · Page 1 of 1 (latest)

supple barn
#

I have two SPAs - site1.domain.com and site2.domain.com - accessing the same Laravel back end application. Each SPA has it's own registration system. When a user receives a verification email I need to change the domain on the URL to match the site that the request has come from.

I have the logic for generating the correct domain but can't see how to tell Laravel to swap it in.

All help greatly appreciated.

supple barn
#

Thanks - that was really helpful. I managed to get a proof of concept working for ResetPassword as it's a pretty straightfoward URL (basically just a token and an email address), but the VerifyEmail URL is proving to be more complicated - it uses a signed route and I'm struggling to see how to create my own signed route. This is the function that VerifyEmail uses -

#
            'verification.verify',
            Carbon::now()->addMinutes(Config::get('auth.verification.expire', 60)),
            [
                'id' => $notifiable->getKey(),
                'hash' => sha1($notifiable->getEmailForVerification()),
            ]
        );
supple barn
#

Ok. I think I have something working as a POC. It's a little clunky but it's functional. In the AppServiceProvider I'm using this -

#
VerifyEmail::createUrlUsing(function($notifiable){
  return $this->getVerificationLink($notifiable);
});
#

which calls this

#
private function getVerificationLink($notifiable){
  return str_replace(env('APP_URL'),$this->getApplicationLink($notifiable),URL::temporarySignedRoute(
          'verification.verify',
          Carbon::now()->addMinutes(Config::get('auth.verification.expire', 120)),
          [
              'uuid' => $notifiable->uuid,
              'hash' => sha1($notifiable->getEmailForVerification()),
          ]
      ));
  }