示例#1
0
 /**
  * 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'];
     }
 }
示例#2
0
<?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');
        }
    }
});
示例#3
0
 /**
  * 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);
 }