Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class User extends Front {
- $layout = 'layouts/user';
- $allowedMethods = array('login', 'logout');
- public function __construct() {
- if(!Auth::logged() && !in_array($currentMethod, $allowedMethods)) {
- return Redirect::home(); //Это будет действовать для всех ниже методов кроме login и logout
- }
- }
- public function index() {
- $data = array();
- $data['user'] = User::find(Auth::user()->id); //сюда никак не попасть Не-авторизованному пользователю
- $this->view('user/index', $data);
- }
- public function login() {
- $login = $this->input->post('login');
- $password = $this->input->post('password');
- $captcha = $this->input->post('captcha');
- if(Auth::login($login, $password) && Captcha::check($captcha) {
- Session::flash('message', $this->lang('login_success'));
- }
- else
- {
- Session::flash('message', $this->lang('login_failure'));
- }
- return Redirect::back();
- }
- public function logout() {
- Auth::logout();
- Session::flash('message', $this->lang('logout_success'));
- return Redirect::back();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement