Closed maguro-my closed 3 years ago
Sorry for late reply, I was so busy with my exam.
If you registered new guard it would be prefixed on route name.
As example, if you have installed multi authentication for 'admin' guard, The route name would admin.verification.verify
I think you didn't registered verification.verify route.
Note: This package installs extra authentication system. For default user, please check laravel/breeze documentation
Thank you for your reply. I noticed the admin.verification.verify is there but when I register an admin, it look for verification.verify route.
I think its now fixed.
I've tagged new version v1.1.4.
If you want to refactor existing installation,
(Let's assume targeted guard is admin)
VerifyEmail::createUrlUsing(function ($notifiable) {
return URL::temporarySignedRoute(
'admin.verification.verify',
Carbon::now()->addMinutes(Config::get('auth.verification.expire', 60)),
[
'id' => $notifiable->getKey(),
'hash' => sha1($notifiable->getEmailForVerification()),
]
);
});
Add this codes in RegisteredUserController before firing Registered event and in EmailVerificationNotificationController before calling sendEmailVerificationNotification method on user model.
I've added a brand new request EmailVerificationRequest used by VerifyEmailController, which extends the default one and customized to resolve custom user.
namespace App\Http\Requests\Admin\Auth;
use Illuminate\Auth\Events\Verified;
use Illuminate\Foundation\Auth\EmailVerificationRequest as Existing;
class EmailVerificationRequest extends Existing
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
if (! hash_equals((string) $this->route('id'),
(string) $this->user('admin')->getKey())) {
return false;
}
if (! hash_equals((string) $this->route('hash'),
sha1($this->user('admin')->getEmailForVerification()))) {
return false;
}
return true;
}
/**
* Fulfill the email verification request.
*
* @return void
*/
public function fulfill()
{
if (! $this->user('admin')->hasVerifiedEmail()) {
$this->user('admin')->markEmailAsVerified();
event(new Verified($this->user('admin')));
}
}
}
Brilliant. Now it works. Thank you for your time.
Hi, I tried to verify email by implementing MustVerifyEmail in user model. I got error when I try to register a user; Route [verification.verify] not defined.