Back

Email Verification Woes


Daniel Price posted 2 weeks ago

Hi all! I've been trying to get Laravel 5.7 email verification working for a few days now without success, and I could really use some help! I'm using Homestead on Ubuntu 18.04. My current error is:

"Call to undefined method Illuminate\Auth\GenericUser::hasVerifiedEmail()"

My User model is:

<?php

namespace App;

use Illuminate\Notifications\Notifiable;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;

class User extends Authenticatable implements MustVerifyEmail
{
    use Notifiable;

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'name', 'email', 'password',
    ];

    /**
     * The attributes that should be hidden for arrays.
     *
     * @var array
     */
    protected $hidden = [
        'password', 'remember_token',
    ];
    
}

The 'missing' method exists in VerifiesEmails.php:

public function show(Request $request)
    {
        return $request->user()->hasVerifiedEmail()
                        ? redirect($this->redirectPath())
                        : view('auth.verify');
    }

This error occurs after registration, when attempting to visit a protected route. As expected, the login view is displayed--but not with any text about email verification--and this error results after entering creds.

Much thanks!

Daniel Price replied 2 weeks ago

Hey! I saw a Stack Overflow post about a similar error, and the suggestion was to change the driver in auth.php from 'database' to 'eloquent'. I did so, and now the app functions as expected. Still not sending email, but at least it's progress... I don't know why the driver was set to 'database' and not 'eloquent', or what potential impacts could result from having changed it, though....


Sign in to participate in this thread!



We'd like to thank these amazing companies for supporting us