sentinel icon indicating copy to clipboard operation
sentinel copied to clipboard

Can I use custom users table (for example of other CMS)?

Open ChefMC opened this issue 5 years ago • 2 comments

I have my own users database from one game. Can I use this existing users database table and authorize players on web-site via Sentinel as framework (for auth, sessions/cookie mechanism, remember me feature, XSS/CSRF protection)?

ChefMC avatar Dec 20 '19 03:12 ChefMC

That's a wonderful question, also I would like if there's any chance to add more field's to the table user, and off-course control those fields?

rscarpim avatar Jan 28 '20 18:01 rscarpim

You need to make your user tables compatible with the classes in src/Users I think, by replacing or extending them.

Adding other fields you can do, I extended EloquentUser, example:

class User extends \Cartalyst\Sentinel\Users\EloquentUser
{
    protected $fillable = [
        'email',
        'password',
        'last_name',
        'first_name',
        'permissions',
        'company',
        'department',
        'title',
        'phone',
        'mobile',
        'manager'
    ];

    protected $loginNames = ['email'];
}

Then I added the configuration (which is the same file from src/config/config.php with changes) before starting the instance

$config = new Cartalyst\Sentinel\Native\ConfigRepository(__DIR__.'/src/customSentinelConfig.php');
$bootstrapper = new Cartalyst\Sentinel\Native\SentinelBootstrapper($config);
Sentinel::instance($bootstrapper);

sabas avatar Feb 02 '20 10:02 sabas