cartalyst / sentinel

A framework agnostic authentication & authorization system.
BSD 3-Clause "New" or "Revised" License
1.51k stars 238 forks source link

Using cartalyst-sentinel registerAndActivate methods how extend fields list? #538

Open sergeynilov opened 3 years ago

sergeynilov commented 3 years ago

Hallo, My laravel 7 app has login /register functionality and I added to my project cartalyst-sentinel 4.x and replacing my code with cartalyst-sentinel methods I got error

Field 'username' doesn't have a default value (SQL: insert intohs3_users(email,password,updated_at,created_at) values (User2@mail.com, $2y$10$TBUJVFfOT1uc7tw3o2dajOd27kpPP5zYQSdf7ifKf7m10IkXgtko2, 2020-09-06 16:28:53, 2020-09-06 16:28:53)) making :

                $newUser = Sentinel::registerAndActivate([
                    'username' => $this->form['username'],
                    'email'    => $this->form['email'],
                    'password' => $this->form['password']
                ]);

I modified migration file from cartalyst-sentinel and added several fields, incuding username. My model app/User.php has :

<?php

namespace App;

use Illuminate\Notifications\Notifiable;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\Storage;

use App\UsersGroups;
use App\Group;

class User extends Authenticatable 
{
    use Notifiable;
    protected $table = 'users';
    protected $primaryKey = 'id';
    public $timestamps = false;

    protected $fillable = [
        'username', 'email', 'password', 'status', 'account_type', 'first_name', 'last_name', 'phone', 'creator_id', 'avatar'
        ...

I found files vendor/cartalyst/sentinel/src/Users/EloquentUser.php and /vendor/cartalyst/sentinel/src/Users/UserInterface.php Have I to reference my model to one of these 2 files? In which way?

Thanks!