Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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