Skip to content

Instantly share code, notes, and snippets.

@crynobone
Last active October 8, 2015 17:38
Show Gist options
  • Select an option

  • Save crynobone/3366342 to your computer and use it in GitHub Desktop.

Select an option

Save crynobone/3366342 to your computer and use it in GitHub Desktop.
Allow OneAuth to use Sentry Auth Driver
<?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