FatalThrowableError
samuelsam225 opened this issue · comments
I have followed your instructions and complement the steps. I have laravel 5.5
when I click the register in my views, I get
Symfony \ Component \ Debug \ Exception \ FatalThrowableError (E_RECOVERABLE_ERROR)
Type error: Argument 1 passed to Lunaweb\EmailVerification\EmailVerification::createToken() must
be an instance of Lunaweb\EmailVerification\Contracts\CanVerifyEmail, instance of App\User given,
called in /Users/sam/site/vendor/josiasmontag/laravel-email-verification/src/EmailVerification.php
on line 127
when I check my database the user values gets insert into the user table. What might be the cause.
Seems you are missing implements CanVerifyEmailContract
in your User
model.
Yea.. true. I am new to laravel.. here is my user model
namespace App;
use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Lunaweb\EmailVerification\Traits\CanVerifyEmail;
use Lunaweb\EmailVerification\Contracts\CanVerifyEmail as CanVerifyEmailContract;
class User implements CanVerifyEmailContract
{
use CanVerifyEmail;
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name', 'email', 'password', 'username',
];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'password', 'remember_token',
];
}
now I am getting
Call to undefined method App\User::newQuery()
and it is showing it here
/Users/sam/site/vendor/laravel/framework/src/Illuminate/Auth/EloquentUserProvider.php
User still needs to extend Authenticatable
, of course. Will clarify README.
ok
this my user model now
namespace App;
use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Lunaweb\EmailVerification\Traits\CanVerifyEmail;
use Lunaweb\EmailVerification\Contracts\CanVerifyEmail as CanVerifyEmailContract;
class User extends Authenticatable implements CanVerifyEmailContract
{
use Notifiable;
use CanVerifyEmail;
protected $fillable = [
'name', 'email', 'password', 'username',
];
protected $hidden = [
'password', 'remember_token',
];
}
and my route
Route::get('/', function () {
return view('welcome');
});
Auth::routes();
Route::group(
['middleware' => ['web', 'auth', 'isEmailVerified']],
function () {
Route::get('/home', 'HomeController@index')->name('home');
}
);
Auth::routes();
Route::group(
['middleware' => ['web', 'auth', 'isEmailVerified']],
function () {
Route::get('/home', 'HomeController@index')->name('home');
}
);
Everything works fine but user is login even without activating his account. I think it is from my route.
Below is a screenshoots after a user clicks on the register
This is intended. The form is shown by the isEmailVerified
middleware.