Exemplo n.º 1
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');
        }
    }
});
Exemplo n.º 2
0
 /**
  * Show the specified user.
  *
  * @param int $id
  *
  * @return \Illuminate\View\View
  */
 public function show($id)
 {
     $user = UserRepository::find($id);
     $this->checkUser($user);
     if ($user->activated_at) {
         $activated = html_ago($user->activated_at);
     } else {
         if (Credentials::hasAccess('admin') && Config::get('credentials.activation')) {
             $activated = 'No - <a href="#resend_user" data-toggle="modal" data-target="#resend_user">Resend Email</a>';
         } else {
             $activated = 'Not Activated';
         }
     }
     if (Credentials::getThrottleProvider()->findByUserId($id)->isSuspended()) {
         $suspended = 'Currently Suspended';
     } else {
         $suspended = 'Not Suspended';
     }
     $groups = $user->getGroups();
     if (count($groups) >= 1) {
         $data = [];
         foreach ($groups as $group) {
             $data[] = $group->name;
         }
         $groups = implode(', ', $data);
     } else {
         $groups = 'No Group Memberships';
     }
     return View::make('credentials::users.show', compact('user', 'groups', 'activated', 'suspended'));
 }