/** * Attempt to find the user id of the currently logged in user. * * @return int|null */ protected function getUserId() { if (Credentials::check()) { return Credentials::getUser()->id; } elseif (isset($this['user_id']) && $this['user_id']) { return $this['user_id']; } }
<?php /* * This file is part of Laravel Credentials. * * (c) Graham Campbell <*****@*****.**> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ use Illuminate\Support\Facades\Redirect; use GrahamCampbell\Credentials\Facades\Credentials; $router->filter('auth.admin', function ($route, $request) { if (Credentials::check()) { if (!Credentials::hasAccess('admin')) { return Redirect::to('/')->with('error', 'You do not have permission to login'); } } });
/** * Adds the user to the given group. * * @param \Cartalyst\Sentry\Groups\GroupInterface $group * * @return bool */ public function addGroup(GroupInterface $group) { if (Credentials::check()) { RevisionRepository::create(['revisionable_type' => get_class($this), 'revisionable_id' => $this->getKey(), 'key' => 'added_group', 'old_value' => null, 'new_value' => $group->getName(), 'user_id' => Credentials::getUser()->id]); } return parent::addGroup($group); }