users()->attach($user); } /** * Log the user out of the application. * * @return bool */ public function logout() { return Sentinel::logout(); } /** * Create an activation code for the given user. * * @param \Modules\User\Entities\User $user * @return \Cartalyst\Sentinel\Activations\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 * @return string */ public function createReminderCode(User $user) { return Reminder::create($user)->code; } /** * Completes the reset password process. * * @param \Modules\User\Entities\User $user * @param string $code * @param string $password * @return bool */ public function completeResetPassword(User $user, $code, $password) { 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) { if (Sentinel::guest()) { return false; } $permissions = is_array($permissions) ? $permissions : func_get_args(); return Sentinel::hasAccess($permissions); } /** * Determine if the current user has access to the any given permissions * * @param array|string $permissions * @return bool */ public function hasAnyAccess($permissions) { if (Sentinel::guest()) { return false; } $permissions = is_array($permissions) ? $permissions : func_get_args(); return Sentinel::hasAnyAccess($permissions); } /** * Check if the user is logged in. * * @return bool */ public function check() { 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. * * @return int|null */ public function id() { return optional($this->user())->id; } }