コード例 #1
0
 /**
  * Login
  *
  * @AclMap(	name="auth_login_page",
  *			config={"only":"guest"},
  *			insufficient_message="acl.login",
  *			redirect={"type":"to","path":"/"})
  */
 public function actionLogin()
 {
     $this->viewData = array('title' => 'Sign In', 'auth_type' => 'sign-in');
     if (Request::instance()->getMethod() == 'POST' || Session::has('tmp_login')) {
         Input::flash();
         $validator = Validator::make(Input::all(), array('email' => 'required|email', 'password' => 'required'));
         if ($validator->fails()) {
             // Initial validation failed...
             $error = $validator->messages()->first();
         } else {
             // Initial validation success, continue...
             try {
                 // Find the user using the login credential
                 $email = Input::get('email', Session::get('tmp_login'));
                 $remember = (bool) Input::get('remember');
                 $user = Sentry::findUserByLogin($email);
                 // Check the password, dont get silly!
                 if (!$user->checkPassword(Input::get('password'))) {
                     $error = 'Incorrect password';
                 } else {
                     // Log the user in
                     $email = $user->email;
                     $password = Input::get('password');
                     $user = Sentry::authenticate(compact('email', 'password'), $remember);
                     // If it has connection, attach it
                     if (Session::has('connection')) {
                         $provider = Session::get('connection.type');
                         $data = new Collection(Session::get('connection.data'));
                         $connection = SocialConnection::create(array('user_id' => $user->id, 'provider' => $provider, 'provider_uid' => $data->get('id'), 'provider_username' => $data->get('username', $data->get('screen_name')), 'name' => $data->get('name'), 'data' => serialize($data->all())));
                         Session::forget('connection');
                     }
                     return Redirect::intended('/');
                 }
             } catch (Cartalyst\Sentry\Users\LoginRequiredException $e) {
                 $error = 'Login field is required.';
             } catch (Cartalyst\Sentry\Users\UserNotActivatedException $e) {
                 Session::flash('activation', $user->email);
                 $error = 'User not activated.';
             } catch (Cartalyst\Sentry\Users\UserNotFoundException $e) {
                 $error = 'User not found.';
             } catch (Cartalyst\Sentry\Throttling\UserSuspendedException $e) {
                 $throttle = Sentry::findThrottlerByUserId($user->id);
                 $time = $throttle->getSuspensionTime();
                 $error = "User is suspended for [{$time}] minutes.";
             } catch (Cartalyst\Sentry\Throttling\UserBannedException $e) {
                 $error = 'User is banned.';
             }
         }
         // Populate any errors
         if (isset($error)) {
             Session::flash('auth_errors', $error);
             return Redirect::route('auth_login');
         }
     }
     $this->setupLayout();
 }
コード例 #2
0
ファイル: User.php プロジェクト: jrafaelca/Doptor
 public static function isBanned($id)
 {
     $throttle = Sentry::findThrottlerByUserId($id);
     if ($throttle->isBanned()) {
         // User is Banned
         return true;
     } else {
         // User is not Banned
         return false;
     }
 }
コード例 #3
0
ファイル: User.php プロジェクト: sgh1986915/laravel-bizgym
 /**
  * Get user's status
  */
 public function getStatus()
 {
     $throttle = Sentry::findThrottlerByUserId($this->id);
     if ($throttle->isBanned()) {
         return 'banned';
     } elseif ($throttle->isSuspended()) {
         return 'suspended';
     } else {
         return $this->isActivated() ? 'active' : 'not active';
     }
 }
コード例 #4
0
ファイル: User.php プロジェクト: ramonkampinga/snipe-it
 public function accountStatus()
 {
     $throttle = Sentry::findThrottlerByUserId($this->id);
     if ($throttle->isBanned()) {
         return 'banned';
     } elseif ($throttle->isSuspended()) {
         return 'suspended';
     } else {
         return '';
     }
 }
コード例 #5
0
                    <th>Username</th>
                    <th>First Name</th>
                    <th>Middle name</th>
                    <th>Last Name</th>
                    <th>Email</th>
                    <th>Type</th>
                    <!--<th>Branch</th>-->
                    <th>Brand</th>
                    <th>Active</th>
                    <th>Action</th>
                </tr>
            </thead>
            <tbody>
                @foreach ($datas['users'] as $user)
                <?php 
$throttle = $throttle = Sentry::findThrottlerByUserId($user->getId());
?>
                
                <tr>
                    @if($currentUser->hasAccess('delete-user'))
                    <td style="text-align: center;">
                        <input type="checkbox" data-user-id="{{ $user->getId(); }}">
                    </td>
                    @endif     
                    <td>{{$user->getId();}}</td>
                    <td>{{$user->username}}</td>
                    <td>{{$user->first_name}}</td>
                    <td>{{$user->middle_name}}</td>
                    <td>{{$user->last_name}}</td>
                    <td>
                        <a rel="nofollow" href="javascript:void(0);">
コード例 #6
0
ファイル: User.php プロジェクト: rafaelvieiras/connect
 /**
  * Unban the user.
  *
  * @return void
  */
 public function unban()
 {
     $throttle = \Sentry::findThrottlerByUserId($this->id);
     $throttle->unBan();
 }
コード例 #7
0
ファイル: UserController.php プロジェクト: Belar/eventpotion
 public function unbanUser($id)
 {
     try {
         // Find the user using the user id
         $throttle = Sentry::findThrottlerByUserId($id);
         // Unban the user
         $throttle->unban();
         return Redirect::to('/neverland')->with('global_success', 'User UNbanned successfully.');
     } catch (Cartalyst\Sentry\Users\UserNotFoundException $e) {
         return Redirect::to('/neverland')->with('global_error', 'There is no such user.');
     }
 }
コード例 #8
0
ファイル: UserRepository.php プロジェクト: ymnl007/92five
 public function manageUsers($data)
 {
     if ($data['action'] == 'activate') {
         try {
             $userId = $data['id'];
             $user = \User::find($userId);
             $user->activated = true;
             $user->activated_at = date_create();
             $user->save();
             return true;
         } catch (\Exception $e) {
             \Log::error('Something Went Wrong in User Repository - manageUsers()-activate:' . $e->getMessage());
             return false;
         }
     }
     if ($data['action'] == 'deactivate') {
         try {
             $userId = $data['id'];
             $user = \User::find($userId);
             $user->activated = false;
             $user->save();
             return true;
         } catch (\Exception $e) {
             \Log::error('Something Went Wrong in User Repository - manageUsers()-deactivate:' . $e->getMessage());
             return false;
         }
     }
     if ($data['action'] == 'unsuspend') {
         try {
             $user = \Sentry::findThrottlerByUserId($data['id']);
             if ($suspend = $user->isSuspended()) {
                 $user->unsuspend();
             } else {
             }
             return true;
         } catch (\Exception $e) {
             \Log::error('Something Went Wrong in User Repository - manageUsers()-unsuspend:' . $e->getMessage());
             return false;
         }
     }
     if ($data['action'] == 'suspend') {
         try {
             $user = \Sentry::findThrottlerByUserId($data['id']);
             if ($suspend = $user->isSuspended()) {
             } else {
                 $user->suspend();
             }
             return true;
         } catch (\Exception $e) {
             \Log::error('Something Went Wrong in User Repository - manageUsers()-suspend:' . $e->getMessage());
             return false;
         }
     }
     if ($data['action'] == 'unbanned') {
         try {
             $user = \Sentry::findThrottlerByUserId($data['id']);
             if ($suspend = $user->isBanned()) {
                 $user->unBan();
             } else {
             }
             return true;
         } catch (\Exception $e) {
             \Log::error('Something Went Wrong in User Repository - manageUsers()-unbanned:' . $e->getMessage());
             return false;
         }
     }
     if ($data['action'] == 'ban') {
         try {
             $user = \Sentry::findThrottlerByUserId($data['id']);
             if ($suspend = $user->isBanned()) {
             } else {
                 $user->ban();
             }
             return true;
         } catch (\Exception $e) {
             \Log::error('Something Went Wrong in User Repository - manageUsers()-ban:' . $e->getMessage());
             return false;
         }
     }
 }
コード例 #9
0
 public function ban_user($id = FALSE)
 {
     if ($this->user->hasAccess('user.all')) {
         // Check $id is set
         if ($id === FALSE || !is_numeric($id)) {
             Session::flash('alert_warning', 'Routing Error. Please try your request again.');
             return Redirect::to('dashboard');
         } else {
             try {
                 // Find the user using the user id
                 $throttle = Sentry::findThrottlerByUserId($id);
                 // Ban the user
                 $throttle->ban();
                 Session::flash('alert_success', 'User was banned.');
                 return Redirect::to('/user');
             } catch (Cartalyst\Sentry\Users\UserNotFoundException $e) {
                 Session::flash('alert_danger', 'Banning Failed. User was not found. Please try again.');
                 return Redirect::to('/user');
             }
         }
     } else {
         Session::flash('alert_danger', 'Access denied.');
         return Redirect::to('dashboard');
     }
 }
コード例 #10
0
 public function manage($dash, $id, $mode)
 {
     switch ($mode) {
         case 'view':
             $theme = Theme::uses('dashboard')->layout('default');
             $view = array('name' => 'Dashboard User', 'id' => $id);
             $theme->breadcrumb()->add([['label' => 'Dashboard', 'url' => Setting::get('system.dashurl')], ['label' => 'Users', 'url' => Setting::get('system.dashurl') . '/users'], ['label' => $id, 'url' => Setting::get('system.dashurl') . '/user/1/view']]);
             $theme->setTitle(Setting::get('system.adminsitename') . ' User');
             $theme->setType('User');
             return $theme->scope('user.view', $view)->render();
             break;
         case 'edit':
             if (Sentry::getUser()->inGroup(Sentry::findGroupByName('admin'))) {
                 $theme = Theme::uses('dashboard')->layout('default');
                 $view = array('name' => 'Dashboard User', 'id' => $id);
                 $theme->breadcrumb()->add([['label' => 'Dashboard', 'url' => Setting::get('system.dashurl')], ['label' => 'Users', 'url' => Setting::get('system.dashurl') . '/users'], ['label' => $id, 'url' => Setting::get('system.dashurl') . '/user/1/edit']]);
                 $theme->setTitle(Setting::get('system.adminsitename') . ' User');
                 $theme->setType('User');
                 return $theme->scope('user.edit', $view)->render();
             } else {
                 return "NOT AUTHORISED";
             }
             break;
         case 'delete':
             $user = Sentry::getUser();
             // Find the Administrator group
             $admin = Sentry::findGroupByName('admin');
             // Check if the user is in the administrator group
             if ($user->inGroup($admin)) {
                 $deleteuser = Sentry::findUserById($id);
                 $usergroup = $deleteuser->getGroups();
                 $usergroupe = json_decode($usergroup, true);
                 $usergroupe[0]['pivot']['group_id'];
                 $group = Sentry::findGroupById($usergroupe[0]['pivot']['group_id']);
                 $groupname = $group->name;
                 if ($groupname == 'teachers') {
                     Teacher::findOrFail($id)->delete();
                 } elseif ($groupname == 'students') {
                     Student::findOrFail($id)->delete();
                 }
                 $deleteuser->delete();
                 return Redirect::to(URL::previous());
             } else {
                 return "UNAUTHORISED ACTION";
             }
             break;
         case 'suspend':
             $user = Sentry::getUser();
             // Find the Administrator group
             $admin = Sentry::findGroupByName('admin');
             // Check if the user is in the administrator group
             if ($user->inGroup($admin)) {
                 $throttle = Sentry::findThrottlerByUserId($id);
                 // Suspend the user
                 $throttle->suspend();
                 return Redirect::to(URL::previous());
             } else {
                 return "UNAUTHORISED ACTION";
             }
             break;
         case 'unsuspend':
             $throttle = Sentry::findThrottlerByUserId($id);
             // Suspend the user
             $throttle->unsuspend();
             return Redirect::to(URL::previous());
             break;
         case 'ban':
             $user = Sentry::getUser();
             // Find the Administrator group
             $admin = Sentry::findGroupByName('admin');
             // Check if the user is in the administrator group
             if ($user->inGroup($admin)) {
                 $throttle = Sentry::findThrottlerByUserId($id);
                 // Suspend the user
                 $throttle->ban();
                 return Redirect::to(URL::previous());
             } else {
                 return "UNAUTHORISED ACTION";
             }
             break;
         case 'unban':
             $throttle = Sentry::findThrottlerByUserId($id);
             // Suspend the user
             $throttle->unban();
             return Redirect::to(URL::previous());
             break;
     }
 }
コード例 #11
0
 public function un_ban($id)
 {
     $user = Sentry::findThrottlerByUserId($id);
     $user->unBan();
     return Redirect::back()->withSuccess('User un-banned');
 }
コード例 #12
0
 /**
  * @brief gets all users
  *
  * @return Mixed
  */
 public function getUsers()
 {
     $users = \Sentry::findAllUsers();
     foreach ($users as $user) {
         $throttle = \Sentry::findThrottlerByUserId($user->id);
         $user['suspended'] = $throttle->isSuspended();
         $user['banned'] = $throttle->isBanned();
         $user['activated'] = $user->isActivated();
     }
     return $users;
 }
コード例 #13
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($lang, $id)
 {
     /*
     $user = Sentry::findUserById($id);
     $user->delete();
     */
     try {
         $throttle = Sentry::findThrottlerByUserId($id);
         if ($banned = $throttle->isBanned()) {
             $throttle->unBan();
             Session::flash('message', trans('kuu-validation.user_was_unbanned_successfully'));
         } else {
             $throttle->ban();
             Session::flash('message', trans('kuu-validation.user_was_banned_successfully'));
         }
     } catch (Cartalyst\Sentry\Users\UserNotFoundException $e) {
         Session::flash('error_message', trans('kuu-validation.user_was_not_found') . ' ' . $id);
     }
     //return Redirect::to('/admin/user?search_string='.Input::get('search_string').'&page='.Input::get('page'));
     return Redirect::route('admin.user', array('lang' => App::getLocale(), 'search_string' => Input::get('search_string'), 'page' => Input::get('page')));
 }
コード例 #14
0
          <td>{{ $user['user_info']['city'] }}, {{ $user['user_info']['state'] }} {{ $user['user_info']['zip'] }}</td>
        </tr>
        <tr>
          <th>Work Phone</th>
          <td>{{ $user['user_info']['work_phone'] }}</td>
        </tr>
        <tr>
          <th>Mobile Phone</th>
          <td>{{ $user['user_info']['mobile_phone'] }}</td>
        </tr>
        <tr>
          <th>Activated</th>
          <td>
            <?php 
try {
    if (Sentry::findThrottlerByUserId($user->id)->isBanned()) {
        ?>
                  <span class="text-danger">Banned</span> <?php 
    } else {
        ?>
                  @if( $user['activated'] == 1 )
                    <span class="text-success">Active</span>
                  @else
                    <span class="text-danger">Not Active</span>
                  @endif <?php 
    }
} catch (Cartalyst\Sentry\Users\UserNotFoundException $e) {
    Log::error(date("Y-m-d H:i:s") . '- RuntimeException in app/views/auth/user_show.blade.php: ' . $e);
}
?>
          </td>
コード例 #15
0
ファイル: events.php プロジェクト: sgh1986915/laravel-bizgym
 case 'auth.register':
     $user = $param;
     // As default, we will assign user group
     $user->addGroup(Sentry::findGroupByName('User'));
     // Log activity
     Event::fire('log.user_activity', array(Logger::LOW, $user->id, array(array('sub_type' => 'auth.register', 'detail' => '%s signed up', 'icon' => 'icon-user', 'deletable' => 0, 'value' => $param))));
     break;
 case 'auth.check_acl':
     // Here we'll get the current request instance
     // thus allowing us to check and dynamically assign roles
     $request = $param;
     // This is initial implementation, as we just check login state
     if (Auth::check()) {
         // If it already login, we will assign 'user'
         $roles = array('user');
         $throttle = Sentry::findThrottlerByUserId(Auth::user()->id);
         if ($throttle->isBanned()) {
             // Nothing we can do about it... :(
             $roles = array('banned');
         } else {
             // Let see their system roles
             foreach (Auth::user()->getGroups() as $group) {
                 $roles[] = strtolower($group->name);
             }
         }
         if ($param instanceof Illuminate\Http\Request) {
             if ($param->is('user/profile')) {
                 // Assign 'me' role
                 $roles[] = 'me';
             }
         }
コード例 #16
0
                <th style="padding: 0px 0px 0px;">
                    @include('admin.user.sorting', array('field_name' => 'Email', 'column_name' => trans('admin.email')))
                </th>
                <th style="padding: 0px 0px 0px;">
                    @include('admin.user.sorting', array('field_name' => 'created_at', 'column_name' => trans('admin.dt_add')))
                </th>
                <th>{{ trans('admin.activated') }}</th>
                <th>{{ trans('admin.groups') }}</th>
                <th>{{ trans('admin.actions') }}</th>
            </tr>
            </thead>

            <tbody>
            @foreach ($users as $user)
            <?php 
$throttle = Sentry::findThrottlerByUserId($user->id);
$banned = $throttle->isBanned();
?>
            <tr>
                <td>{{ $user->getFullName() }}</td>
                <td>{{ $user->email }}</td>
                <td>{{ $user->created_at->format('F d, Y h:ia') }}</td>
                <td>{{ ($user->activated) ? '<i class="icon-ok icon-black"></i>' : '<i class="icon-remove icon-black"></i>' }}</td>
                <td>
                    @foreach ($user->groups()->get() as $group)
                    <a href="#" class="btn btn-small disabled">{{$group->name}}</a>
                    @endforeach
                </td>
                <td style="width:250px">
                    <a href="{{ URL::route('admin.check',array('lang' =>App::getLocale())) }}/{{ $user->id }}" class="btn pull-left" style="margin-right: 3px;"><i class="icon-check"></i>{{ trans('admin.checks') }}</a>
                    <a href="{{ URL::route('admin.user',array('lang' =>App::getLocale())) }}/{{ $user->id }}/edit" class="btn btn-info pull-left" style="margin-right: 3px;">{{ trans('admin.edit') }}</a>
コード例 #17
0
      <tbody>

      @foreach ($users as $user)
        <tr>
          <td><a href="mailto:{{ $user['email'] }}" target="_blank">{{ $user['email'] }}</a>
            @if( isset($user["new"]) && $user["new"] === "new" )
              &nbsp;<span class="badge badge-success"> {{ $user["new"] }} </span>
            @endif
          </td>
          <td>{{ $user['user_details']['last_name'] }}</td>
          <td>{{ $user['user_details']['first_name'] }}</td>
          <td>{{ $user['user_details']['company_name'] }}</td>
          <td> 
            <?php 
try {
    if (Sentry::findThrottlerByUserId($user['id'])->isBanned()) {
        ?>
                  <span class="text-danger">Banned</span> <?php 
    } else {
        ?>
                  @if( $user['activated'] == 1 )
                    <span class="text-success">Active</span>
                  @else
                    <span class="text-danger">Not Active</span>
                  @endif <?php 
    }
} catch (Cartalyst\Sentry\Users\UserNotFoundException $e) {
    Log::error(date("Y-m-d H:i:s") . '- RuntimeException in app/views/auth/user_show.blade.php: ' . $e);
}
?>
          </td>