3

I set up a multi auth Laravel system with two guards: "user" and "customer". Now I would like to verify the mail of new registered customers (but not of the users).

I've added

use Illuminate\Contracts\Auth\MustVerifyEmail;

and

class Customer extends Authenticatable implements MustVerifyEmail

to Custom model.

I've added

Route::get('email/resend', 'CustomerAuth\VerificationController@resend')->name('verification.resend');
Route::get('email/verify', 'CustomerAuth\VerificationController@show')->name('verification.notice');
Route::get('email/verify/{id}', 'CustomerAuth\VerificationController@verify')->name('verification.verify');

to Routes

I've builded "verify.blade" in views/auth

I've created CustomerAuth\VerificationController

Now Laravel sends a verification email to new customer, but it doesn't verify it nor show any message. If the customer clicks on the verification link Laravel sends back the customer to home.

Here app/Http/Controllers/CustomerAuth/VerificationController.php

namespace App\Http\Controllers\CustomerAuth;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\VerifiesEmails;
class VerificationController extends Controller
{    
use VerifiesEmails;

protected $redirectTo = '/home';

public function __construct()
{
    $this->middleware('auth');
    $this->middleware('signed')->only('verify');
    $this->middleware('throttle:6,1')->only('verify', 'resend');
}
}

I've tried also $this->middleware('auth:customer');

auth.php

return [
'defaults' => [
'guard' => 'user',
'passwords' => 'users',
],
'guards' => [
'user' => [
'driver' => 'session',
'provider' => 'users',
],
'customer' => [
'driver' => 'session',
'provider' => 'customers',
],
'web' => [
'driver' => 'session',
'provider' => 'users',
],
'api' => [
'driver' => 'token',
'provider' => 'users',
'hash' => false,
],
],
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => App\User::class,
],
'customers' => [
'driver' => 'eloquent',
'model' => App\Customer::class,
],
],
'passwords' => [
'customers' => [
'provider' => 'customers',
'table' => 'customer_password_resets',
'expire' => 60,
],
'users' => [
'provider' => 'users',
'table' => 'user_password_resets',
'expire' => 60,
],  
],
];
Gio Lenzi Bis
  • 31
  • 1
  • 2

0 Answers0