Advertisement
Guest User

Untitled

a guest
Jul 16th, 2016
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. public class User extends Front {
  2.  
  3. $layout = 'layouts/user';
  4. $allowedMethods = array('login', 'logout');
  5.  
  6. public function __construct() {
  7.  
  8. if(!Auth::logged() && !in_array($currentMethod, $allowedMethods)) {
  9.  
  10. return Redirect::home(); //Это будет действовать для всех ниже методов кроме login и logout
  11.  
  12. }
  13.  
  14.  
  15. }
  16.  
  17. public function index() {
  18.  
  19. $data = array();
  20. $data['user'] = User::find(Auth::user()->id); //сюда никак не попасть Не-авторизованному пользователю
  21.  
  22. $this->view('user/index', $data);
  23.  
  24. }
  25.  
  26. public function login() {
  27.  
  28. $login = $this->input->post('login');
  29. $password = $this->input->post('password');
  30. $captcha = $this->input->post('captcha');
  31. if(Auth::login($login, $password) && Captcha::check($captcha) {
  32.  
  33. Session::flash('message', $this->lang('login_success'));
  34. }
  35. else
  36. {
  37.  
  38. Session::flash('message', $this->lang('login_failure'));
  39. }
  40. return Redirect::back();
  41.  
  42. }
  43.  
  44. public function logout() {
  45.  
  46. Auth::logout();
  47. Session::flash('message', $this->lang('logout_success'));
  48. return Redirect::back();
  49.  
  50.  
  51. }
  52.  
  53.  
  54.  
  55.  
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement