當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Sentry::attempts方法代碼示例

本文整理匯總了PHP中Sentry::attempts方法的典型用法代碼示例。如果您正苦於以下問題:PHP Sentry::attempts方法的具體用法?PHP Sentry::attempts怎麽用?PHP Sentry::attempts使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Sentry的用法示例。


在下文中一共展示了Sentry::attempts方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: before

 public function before()
 {
     parent::before();
     // if user not connected and not on the login, 404 or session_up pages then redirect to login page
     if (Request::active()->action != 'login' && !Sentry::check() && Request::active()->action != '404' && Request::active()->action != 'session_up') {
         Session::set(array('redirect' => Request::active()->route->translation));
         Response::redirect('login');
     }
     $this->current_user = self::current_user();
     View::set_global('current_user', self::current_user());
     if (Sentry::check()) {
         // logout if banned
         if (Sentry::attempts($this->current_user->username)->get() == Sentry::attempts()->get_limit()) {
             Session::set_flash('Your account has been blocked');
             Sentry::logout();
             Response::redirect('login');
         }
     }
     View::set_global('site_title', 'IKON Backend');
     View::set_global('separator', '/');
     foreach (Model_Forms::find('all') as $k => $form) {
         $this->tables[$k]['cleanName'] = $form->cleanName;
         $this->tables[$k]['url'] = $form->url;
         $this->tables[$k]['table'] = $form->table;
     }
     View::set_global('tables', $this->tables);
 }
開發者ID:roine,項目名稱:wawaw,代碼行數:27,代碼來源:base.php

示例2: action_login

 public function action_login()
 {
     $redirect = Session::get('redirect');
     $vars = array('email' => 'jonathan@ikonfx.com', 'password' => '123456', 'username' => 'jonathan', 'metadata' => array('first_name' => 'jonathan', 'last_name' => 'de montalembert', 'department' => 'test'));
     // $user_id = Sentry::user()->create($vars, true);
     if (Sentry::check()) {
         Response::redirect($redirect);
     }
     $this->template = \View::forge('login');
     if (Input::post()) {
         if (Sentry::user_exists(Input::post('username'))) {
             // User exists
             if (Sentry::attempts()->get_limit() > Sentry::attempts(Input::post('username'))->get()) {
                 // max attempts not reached
                 $valid_login = Sentry::login(Input::post('username'), Input::post('password'));
                 if ($valid_login) {
                     Session::set_flash('success', 'Welcome back ' . ucwords(Input::post('username')));
                     Response::redirect($redirect);
                 } else {
                     $data['username'] = Input::post('username');
                     $data['password'] = Input::post('password');
                     Session::set_flash('error', 'Username OR/AND Password incorrects. You tried ' . Sentry::attempts(Input::post('username'))->get() . '/' . Sentry::attempts()->get_limit());
                 }
             } else {
                 // max attempts reached
                 Session::set_flash('error', 'You\'ve reached your max attempts and will have to wait for ' . Sentry::attempts(Input::post('username'))->get_time() . ' minutes');
             }
         } else {
             // user do not exists
             Session::set_flash('error', 'User do not exists');
         }
     }
     $this->template->title = $data['title'] = 'Welcome to IKON backoffice';
     $this->template->custom_class = 'special_page';
     $this->template->content = View::forge('welcome/login', $data);
 }
開發者ID:roine,項目名稱:wawaw,代碼行數:36,代碼來源:welcome.php

示例3: action_unblock

 public function action_unblock()
 {
     if (!Sentry::user()->has_access('users_unblock')) {
         return;
     }
     $user_id = Input::post('user_id');
     if ($user_id == null) {
         throw new Exception('user id cannot be empty');
     }
     $data['json'] = Sentry::attempts($user_id)->clear();
     $this->template->content = View::forge('ajax/view', $data);
 }
開發者ID:roine,項目名稱:wawaw,代碼行數:12,代碼來源:ajax.php

示例4: check

 public function check()
 {
     $user = Sentry::user();
     $user_id = $user['username'];
     return Sentry::attempts()->get_limit() > Sentry::attempts($user_id)->get();
 }
開發者ID:roine,項目名稱:wawaw,代碼行數:6,代碼來源:attempts.php

示例5: array

        ?>
						<td class='suspend'><input type='checkbox' <?php 
        if (Sentry::attempts()->get_limit() <= $attempts) {
            echo 'checked=checked';
        }
        ?>
></td>
					<?php 
    }
    ?>

					<?php 
    if (Sentry::user()->has_access('users_view')) {
        ?>
					<td class='username'><?php 
        echo Sentry::attempts()->get_limit() <= $attempts ? Html::anchor('users/view/' . $user['id'], $user['username'], array('class' => 'blocked')) : Html::anchor('users/view/' . $user['id'], $user['username']);
        ?>
</td>
				<?php 
    } else {
        ?>
				<td class='username'><?php 
        echo $user['username'];
        ?>
</td>
			<?php 
    }
    ?>

			<td class='email'><?php 
    echo $user['email'];
開發者ID:roine,項目名稱:wawaw,代碼行數:31,代碼來源:index.php


注:本文中的Sentry::attempts方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。