コード例 #1
0
ファイル: base.php プロジェクト: roine/wawaw
 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
0
ファイル: welcome.php プロジェクト: roine/wawaw
 public function action_login()
 {
     $redirect = Session::get('redirect');
     $vars = array('email' => '*****@*****.**', '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
0
ファイル: ajax.php プロジェクト: roine/wawaw
 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
0
ファイル: attempts.php プロジェクト: roine/wawaw
 public function check()
 {
     $user = Sentry::user();
     $user_id = $user['username'];
     return Sentry::attempts()->get_limit() > Sentry::attempts($user_id)->get();
 }
コード例 #5
0
ファイル: index.php プロジェクト: roine/wawaw
        ?>
						<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'];