本文整理汇总了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);
}
示例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);
}
示例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);
}
示例4: check
public function check()
{
$user = Sentry::user();
$user_id = $user['username'];
return Sentry::attempts()->get_limit() > Sentry::attempts($user_id)->get();
}
示例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'];