mercredi 23 septembre 2015

Extending Authentication in Laravel 5.1

I have an application, similar to what hosting resellers get exept something different... this application is used on domainA.com and domainB.com. Both domains point at a single server, so both site run off single app exactly same files and single database.

When user accesses domainA.com we would see specific preferences for domainA i.e. logo and colour scheme. Same applies for domainB.com.

While both domains use single database, I want userA to be able to register on domainA and domainB with same email. When user is to try to login we would use something similar to: (taken from http://ift.tt/1Fu3ym1)

Auth::attempt(['email' => $email, 'password' => $password, 'site' => 'domainA.com'])

This is functionality that I require is needed in order to keep data separate so that if you login as an adminA that belongs to domainA.com you would see what userA did on domainA.com and adminA wouldn NOT see what userA did on domainB.com. Same applies to adminB that belongs to domainB.com, adminB wouldn't be able to see what userA did on domainA.com.

I would like to know on how overall Authentication supplied with Laravel 5 be affected if I was to update default AuthController@create method with something similar to:

    protected function create(array $data)
    {        
        return User::create([
            'name' => $data['name'],
            'email' => $data['email'],
            'password' => bcrypt($data['password']),
            'site' => 'domainB.com'
        ]);
    }

I assume that password reminder can be easily updated, but because Laravel's authentication includes quite alot of built in functionality this might pose an issue unless after authentication user's identifier is used to identify user and to perform core functions



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire