Skip to content
This repository has been archived by the owner on Jan 29, 2021. It is now read-only.
/ sentry-auth Public archive

A drop-in replacement for Laraval 4's native authentication, using Sentry and Laravels Auth Drivers

Notifications You must be signed in to change notification settings

kevbaldwyn/sentry-auth

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Introduction

Sentry Auth is designed to be a drop in replacement for the native Laravel Auth system. It provides the same native API as the Auth class but also adds Sentry's own API to it natively. It also binds the Sentry User and Group model APIs to your Eloquent Model, along with mapping the Sentry Hash API to Laravel's.

Installation

Add the following to your composer.json file

"repositories": [
    {
    	"type":"composer",
        "url" : "http://packages.purepixel.co.uk"
    }
]

And the requirement

"kevbaldwyn/sentry-auth":"dev-master"

Then composer update

Add the providers to app/config/app.php

'providers' => array(
	
	...
	
	'Cartalyst\Sentry\SentryServiceProvider', // Sentry must be defined first
	'KevBaldwyn\SentryAuth\SentryAuthServiceProvider'
	
	...

Add Sentry Facade to app/config/app.php

'aliases' => array(	
	...
	
	'Sentry' => 'Cartalyst\Sentry\Facades\Laravel\Sentry'
	...

Configuration

The package uses a couple of config options to bind the User and Group Models.

sentry-auth/src/config/sentry.php

'users' => array(

	'model' => 'KevBaldwyn\SentryAuth\Models\User'

)

You can then extend this class to create your own models:

// app/models/User.php:
class User extends \KevBaldwyn\SentryAuth\Models\User {
	
	// your own model definition
	
}

Then update the model config

// app/config/packages/kevbaldwyn/sentry-auth/sentry.php
'users' => array(

	'model' => 'User'

)

sentry-auth/src/config/sentry.php can be used to overwrite any sentry default config options by defining any sentry config options with the same keys as you'd find in cartalyst/sentry/src/config/config.php

Examples

You can use all native Auth class methods the same way plus additionally you can call Sentry methods natively from the same Auth API

$user = Auth::register(array(
    'email'    => '[email protected]',
    'password' => 'test',
));
// user will be an Eloquent Model with access to all of Sentry's user API
$activationCode = $user->getActivationCode();
var_dump($activationCode);

Auth::loginUsingId(1);
var_dump(Auth::user()->email);


$credentials = array(
    'email'    => '[email protected]',
    'password' => 'test',
);
Auth::once($credentials);


// Sentry User methods mapped directly to Eloquent model
User::findByCredentials(array(
	    'email'      => '[email protected]',
	    'password'   => 'test')
);

//$group = Group::create(array(
    'name'        => 'Users',
    'permissions' => array(
        'admin' => 1,
        'users' => 1,
    ),
));


$user = User::create(array(
    'email'    => '[email protected]',
    'password' => 'test',
));

// Assign the group to the user
$user->addGroup($group);

About

A drop-in replacement for Laraval 4's native authentication, using Sentry and Laravels Auth Drivers

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages