¨4.0.1¨
This commit is contained in:
@@ -9,6 +9,7 @@ use Cartalyst\Sentinel\Laravel\Facades\Reminder;
|
||||
use Cartalyst\Sentinel\Laravel\Facades\Sentinel;
|
||||
use Modules\User\Events\UserHasActivatedAccount;
|
||||
use Cartalyst\Sentinel\Laravel\Facades\Activation;
|
||||
use Cartalyst\Sentinel\Activations\ActivationInterface;
|
||||
|
||||
class SentinelAuthentication implements Authentication
|
||||
{
|
||||
@@ -17,6 +18,7 @@ class SentinelAuthentication implements Authentication
|
||||
*
|
||||
* @param array $credentials
|
||||
* @param bool $remember
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function login($credentials, $remember = false)
|
||||
@@ -24,10 +26,12 @@ class SentinelAuthentication implements Authentication
|
||||
return Sentinel::authenticate($credentials, $remember);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Register a new user.
|
||||
*
|
||||
* @param array $data
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function register($data)
|
||||
@@ -35,22 +39,26 @@ class SentinelAuthentication implements Authentication
|
||||
return Sentinel::register($data);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Register and activate a new user.
|
||||
*
|
||||
* @param array $data
|
||||
* @return \Modules\User\Entities\User
|
||||
*
|
||||
* @return User
|
||||
*/
|
||||
public function registerAndActivate($data)
|
||||
{
|
||||
return Sentinel::registerAndActivate($data);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Activate the given used id.
|
||||
*
|
||||
* @param int $userId
|
||||
* @param string $code
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function activate($userId, $code)
|
||||
@@ -62,11 +70,13 @@ class SentinelAuthentication implements Authentication
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Assign a role to the given user.
|
||||
*
|
||||
* @param \Modules\User\Entities\User $user
|
||||
* @param \Modules\User\Entities\Role $role
|
||||
* @param User $user
|
||||
* @param Role $role
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function assignRole(User $user, Role $role)
|
||||
@@ -74,6 +84,7 @@ class SentinelAuthentication implements Authentication
|
||||
$role->users()->attach($user);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Log the user out of the application.
|
||||
*
|
||||
@@ -84,21 +95,25 @@ class SentinelAuthentication implements Authentication
|
||||
return Sentinel::logout();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create an activation code for the given user.
|
||||
*
|
||||
* @param \Modules\User\Entities\User $user
|
||||
* @return \Cartalyst\Sentinel\Activations\ActivationInterface
|
||||
* @param User $user
|
||||
*
|
||||
* @return ActivationInterface
|
||||
*/
|
||||
public function createActivation(User $user)
|
||||
{
|
||||
return Activation::create($user)->code;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create a reminders code for the given user.
|
||||
*
|
||||
* @param \Modules\User\Entities\User $user
|
||||
* @param User $user
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function createReminderCode(User $user)
|
||||
@@ -106,12 +121,14 @@ class SentinelAuthentication implements Authentication
|
||||
return Reminder::create($user)->code;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Completes the reset password process.
|
||||
*
|
||||
* @param \Modules\User\Entities\User $user
|
||||
* @param User $user
|
||||
* @param string $code
|
||||
* @param string $password
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function completeResetPassword(User $user, $code, $password)
|
||||
@@ -119,10 +136,12 @@ class SentinelAuthentication implements Authentication
|
||||
return Reminder::complete($user, $code, $password);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Determines if the current user has access to the given permissions.
|
||||
*
|
||||
* @param array|string $permissions
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasAccess($permissions)
|
||||
@@ -136,10 +155,12 @@ class SentinelAuthentication implements Authentication
|
||||
return Sentinel::hasAccess($permissions);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Determine if the current user has access to the any given permissions
|
||||
* Determine if the current user has access to any given permissions
|
||||
*
|
||||
* @param array|string $permissions
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasAnyAccess($permissions)
|
||||
@@ -153,6 +174,7 @@ class SentinelAuthentication implements Authentication
|
||||
return Sentinel::hasAnyAccess($permissions);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if the user is logged in.
|
||||
*
|
||||
@@ -163,15 +185,6 @@ class SentinelAuthentication implements Authentication
|
||||
return Sentinel::check();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the currently logged in user.
|
||||
*
|
||||
* @return \Modules\User\Entities\User|null
|
||||
*/
|
||||
public function user()
|
||||
{
|
||||
return Sentinel::getUser();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the ID for the currently authenticated user.
|
||||
@@ -182,4 +195,15 @@ class SentinelAuthentication implements Authentication
|
||||
{
|
||||
return optional($this->user())->id;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the currently logged-in user.
|
||||
*
|
||||
* @return User|null
|
||||
*/
|
||||
public function user()
|
||||
{
|
||||
return Sentinel::getUser();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user