Skip to content

Instantly share code, notes, and snippets.

@ahkui
Forked from Bodom78/laravel-mongodb-sentinel
Created January 1, 2018 11:25
Show Gist options
  • Select an option

  • Save ahkui/68c49f5034b3b3e72a0303d254ca027a to your computer and use it in GitHub Desktop.

Select an option

Save ahkui/68c49f5034b3b3e72a0303d254ca027a to your computer and use it in GitHub Desktop.

Revisions

  1. @Bodom78 Bodom78 revised this gist Aug 4, 2015. 1 changed file with 74 additions and 0 deletions.
    74 changes: 74 additions & 0 deletions laravel-mongodb-sentinel
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,6 @@
    Work in Progress: More testing to be done.
    At a glance Authentication, Activation, Throttle, Groups & Permissions seem to
    be working.

    Downside: Copy and modify files.
    Upside: Not really much work to get it up and running.
    @@ -70,4 +72,76 @@ checkpoints are disabled in the configuration. To get the checkpoints
    working we need to modify the ServiceProvider and copy/modify some
    Repository files.

    Copy the following vendor files
    -------------------------------------------------------------------------
    \vendor\cartalyst\sentinel\src\Activations\IlluminateActivationRepository.php
    \vendor\cartalyst\sentinel\src\Throttling\IlluminateThrottleRepository.php
    \vendor\cartalyst\sentinel\src\Laravel\SentinelServiceProvider.php

    To your application folder
    -------------------------------------------------------------------------
    \app\Sentinel\Activations\IlluminateActivationRepository.php
    \app\Sentinel\Throttling\IlluminateThrottleRepository.php
    \app\Sentinel\Laravel\SentinelServiceProvider.php

    In the IlluminateActivationRepository.php file
    -------------------------------------------------------------------------
    CHANGE
    namespace Cartalyst\Sentinel\Activations;
    TO
    namespace App\Sentinel\Activations;

    ADD
    use Cartalyst\Sentinel\Activations\ActivationRepositoryInterface;

    Modify the create method by adding
    $activation->completed = false; before the save.

    In the IlluminateThrottleRepository.php file
    -------------------------------------------------------------------------
    CHANGE
    namespace Cartalyst\Sentinel\Throttling;
    TO
    namespace App\Sentinel\Throttling;

    ADD
    use Cartalyst\Sentinel\Throttling\ThrottleRepositoryInterface;

    In the SentinelServiceProvider.php file
    -------------------------------------------------------------------------
    CHANGE
    namespace Cartalyst\Sentinel\Laravel;
    TO
    namespace App\Sentinel\Laravel;

    CHANGE
    use Cartalyst\Sentinel\Activations\IlluminateActivationRepository;
    TO
    use App\Sentinel\Activations\IlluminateActivationRepository;

    CHANGE
    use Cartalyst\Sentinel\Throttling\IlluminateThrottleRepository;
    TO
    use App\Sentinel\Throttling\IlluminateThrottleRepository;

    In the prepareResources method update the paths to the vendor folder to avoid errors.
    CHANGE
    '/../config/config.php'
    TO
    '/../../../vendor/cartalyst/sentinel/src/config/config.php'

    CHANGE
    '/../migrations'
    TO
    '/../../../vendor/cartalyst/sentinel/src/migrations'

    Use the copied and modified Service Provider. In your app config providers
    -------------------------------------------------------------------------
    CHANGE
    'Cartalyst\Sentinel\Laravel\SentinelServiceProvider'
    TO
    'App\Sentinel\Laravel\SentinelServiceProvider'

    Now Authentication, Activation, Throttle, Groups & Permissions should be working.
    Remember to add some unique constraints to the roles->slug and users->email or whatever
    identifier you go with.
  2. @Bodom78 Bodom78 revised this gist Aug 4, 2015. 1 changed file with 10 additions and 2 deletions.
    12 changes: 10 additions & 2 deletions laravel-mongodb-sentinel
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,7 @@
    Work in Progress: Creation, Activation, Login, Logout have been quickly tested.
    Work in Progress: More testing to be done.

    Downside: Copy and modify files.
    Upside: Not really much work to get it up and running.

    Assumes you have Laravel 5.1, jenssegers/laravel-mongodb + session addon set up
    and your app is namespaced to App/
    @@ -62,4 +65,9 @@ CHANGE
    TO
    'model' => 'App\Sentinel\Users\EloquentUser'

    At this stage Auth will be working if the activation and throttle checkpoints are disabled in the configuration.
    At this stage Login/Out will be working if the activation and throttle
    checkpoints are disabled in the configuration. To get the checkpoints
    working we need to modify the ServiceProvider and copy/modify some
    Repository files.


  3. @Bodom78 Bodom78 revised this gist Aug 4, 2015. 1 changed file with 15 additions and 9 deletions.
    24 changes: 15 additions & 9 deletions laravel-mongodb-sentinel
    Original file line number Diff line number Diff line change
    @@ -8,11 +8,6 @@ Install Sentinel 2.x and publish the configuration as per their instructions.
    Because Sentinel models use the default Eloquent Model, we will need to copy
    these and modify to use the MongoDB Model.

    We will also need to copy and modify the service provider to use a modified
    version of the activation class as it fails by default expecting the activation
    tables "completed" column to be false by default but it actually null when the
    key does not exist in mongodb.

    Copy the following vendor model files
    -------------------------------------------------------------------------
    \vendor\cartalyst\sentinel\src\Activations\EloquentActivation.php
    @@ -31,16 +26,16 @@ To your application folder
    \app\Sentinel\Throttling\EloquentThrottle.php
    \app\Sentinel\Users\EloquentUser.php

    In each of the Model files copied over change namespace
    In each of the Model files copied over
    -------------------------------------------------------------------------
    FROM
    CHANGE
    namespace Cartalyst\Sentinel\...;
    TO
    namespace App\Sentinel\...;

    In each of the Model files copied over change Model use
    In each of the Model files copied over
    -------------------------------------------------------------------------
    FROM
    CHANGE
    use Illuminate\Database\Eloquent\Model;
    TO
    use Jenssegers\MongoDB\Model;
    @@ -57,3 +52,14 @@ In the EloquentUser.php file add
    -------------------------------------------------------------------------
    use Cartalyst\Sentinel\Users\UserInterface;

    Update Sentinel Config
    -------------------------------------------------------------------------
    Now update the published Sentinel config so that all references to models
    are using the copied files in you app, example for the user config option:

    CHANGE
    'model' => 'Cartalyst\Sentinel\Users\EloquentUser'
    TO
    'model' => 'App\Sentinel\Users\EloquentUser'

    At this stage Auth will be working if the activation and throttle checkpoints are disabled in the configuration.
  4. @Bodom78 Bodom78 revised this gist Aug 4, 2015. 1 changed file with 9 additions and 6 deletions.
    15 changes: 9 additions & 6 deletions laravel-mongodb-sentinel
    Original file line number Diff line number Diff line change
    @@ -1,14 +1,17 @@
    Work in Progress: Creation, Activation, Login, Logout have been quickly tested.

    Assumes you have Laravel 5.1, jenssegers/laravel-mongodb + session addon set up and your app is namespaced to App/
    Assumes you have Laravel 5.1, jenssegers/laravel-mongodb + session addon set up
    and your app is namespaced to App/

    Install Sentinel 2.x and publish the configuration as per their instructions.

    Because Sentinel models use the default Eloquent Model, we will need to copy these and modify to use the MongoDB Model.
    Because Sentinel models use the default Eloquent Model, we will need to copy
    these and modify to use the MongoDB Model.

    We will also need to copy and modify the service provider to use a modified version of the activation class as it fails
    by default expecting the activation tables "completed" column to be false by default but it actually null when the key does
    not exist in mongodb.
    We will also need to copy and modify the service provider to use a modified
    version of the activation class as it fails by default expecting the activation
    tables "completed" column to be false by default but it actually null when the
    key does not exist in mongodb.

    Copy the following vendor model files
    -------------------------------------------------------------------------
    @@ -40,7 +43,7 @@ In each of the Model files copied over change Model use
    FROM
    use Illuminate\Database\Eloquent\Model;
    TO
    use Jenssegers\Eloquent\Model;
    use Jenssegers\MongoDB\Model;

    In the EloquentPersistence.php file add
    -------------------------------------------------------------------------
  5. @Bodom78 Bodom78 created this gist Aug 4, 2015.
    56 changes: 56 additions & 0 deletions laravel-mongodb-sentinel
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,56 @@
    Work in Progress: Creation, Activation, Login, Logout have been quickly tested.

    Assumes you have Laravel 5.1, jenssegers/laravel-mongodb + session addon set up and your app is namespaced to App/

    Install Sentinel 2.x and publish the configuration as per their instructions.

    Because Sentinel models use the default Eloquent Model, we will need to copy these and modify to use the MongoDB Model.

    We will also need to copy and modify the service provider to use a modified version of the activation class as it fails
    by default expecting the activation tables "completed" column to be false by default but it actually null when the key does
    not exist in mongodb.

    Copy the following vendor model files
    -------------------------------------------------------------------------
    \vendor\cartalyst\sentinel\src\Activations\EloquentActivation.php
    \vendor\cartalyst\sentinel\src\Persistences\EloquentPersistence.php
    \vendor\cartalyst\sentinel\src\Reminders\EloquentReminder.php
    \vendor\cartalyst\sentinel\src\Roles\EloquentRole.php
    \vendor\cartalyst\sentinel\src\Throttling\EloquentThrottle.php
    \vendor\cartalyst\sentinel\src\Users\EloquentUser.php

    To your application folder
    -------------------------------------------------------------------------
    \app\Sentinel\Activations\EloquentActivation.php
    \app\Sentinel\Persistences\EloquentPersistence.php
    \app\Sentinel\Reminders\EloquentReminder.php
    \app\Sentinel\Roles\EloquentRole.php
    \app\Sentinel\Throttling\EloquentThrottle.php
    \app\Sentinel\Users\EloquentUser.php

    In each of the Model files copied over change namespace
    -------------------------------------------------------------------------
    FROM
    namespace Cartalyst\Sentinel\...;
    TO
    namespace App\Sentinel\...;

    In each of the Model files copied over change Model use
    -------------------------------------------------------------------------
    FROM
    use Illuminate\Database\Eloquent\Model;
    TO
    use Jenssegers\Eloquent\Model;

    In the EloquentPersistence.php file add
    -------------------------------------------------------------------------
    use Cartalyst\Sentinel\Persistences\PersistenceInterface;

    In the EloquentRole.php file add
    -------------------------------------------------------------------------
    use Cartalyst\Sentinel\Roles\RoleInterface;

    In the EloquentUser.php file add
    -------------------------------------------------------------------------
    use Cartalyst\Sentinel\Users\UserInterface;