Last active
October 8, 2015 17:38
-
-
Save crynobone/3366342 to your computer and use it in GitHub Desktop.
Allow OneAuth to use Sentry Auth Driver
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /* | |
| |-------------------------------------------------------------------------- | |
| | OneAuth IoC | |
| |-------------------------------------------------------------------------- | |
| | | |
| | Register Auth adapter as IoC, allow it to be replaced by any Authentication | |
| | bundle that doesn't use Laravel\Auth\Drivers | |
| */ | |
| // Check whether current user is logged-in to the system or a guest | |
| IoC::register('oneauth.driver: auth.check', function () | |
| { | |
| return Sentry::check(); | |
| }); | |
| // Get logged in user, if the user doesn't logged in yet, return null | |
| IoC::register('oneauth.driver: auth.user', function () | |
| { | |
| if ( ! Sentry::check()) return null; | |
| return Sentry::user(); | |
| }); | |
| // Login the user by users.id | |
| IoC::register('oneauth.driver: auth.login', function ($user_id) | |
| { | |
| return Sentry::force_login($user_id); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment