Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2014
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.56 KB | None | 0 0
  1. <?php
  2. class UsersController extends AppController {
  3.  
  4. var $name = 'Users';
  5. var $components = array('Auth', 'Acl');
  6.  
  7.  
  8. function beforeFilter(){
  9. //parent::beforeFilter();
  10. $this->Auth->loginError = "asdad!";
  11. $this->Auth->authError = "sdsd !.";
  12. App::uses('CakeEmail', 'Network/Email');
  13. $this->Auth->userModel = 'User';
  14. $this->Auth->allow('login','register','login','step2','TakeId','kontakt');
  15. }
  16. function login(){
  17. if(!empty($this->data)){
  18. $this->request->data['User']['password'] = AuthComponent::password($this->request->data['User']['password']);
  19. $sprawdz = $this->User->find('first',array('conditions'=>array('User.username'=>$this->request->data['User']['username'],'User.password'=>$this->request->data['User']['password'])));
  20. echo debug($sprawdz);
  21. if(!empty($sprawdz)){
  22. if($this->Auth->login($this->request->data)){
  23. $this->redirect('/');
  24. echo debug('you are log in!') ;
  25. }
  26. }
  27. else {
  28. $this->User->invalidate('username', 'mistake!');
  29. }
  30. }
  31. }
  32.  
  33. function logout(){
  34. $this->Auth->logout();
  35. $this->redirect('/');
  36. }
  37. }
  38.  
  39. <?php echo $this->Session->flash('auth'); ?>
  40. <?php echo $this->Form->create('User'); ?>
  41. <fieldset>
  42. <?php echo $this->Form->input('username');
  43. echo $this->Form->input('password'); ?>
  44. </fieldset>
  45. <?php echo $this->Form->end(__('Log in')); ?>
  46.  
  47. function login(){
  48. if ($this->request->is('post')) {
  49. if ($this->Auth->login()) {
  50. $this->Session->setFlash('You have successfully logged in the system');
  51. return $this->redirect('/');
  52. }
  53. $this->Session->setFlash(__('Invalid username or password, try again [warning]'));
  54. }
  55. }
  56.  
  57. function login(){
  58. if(!empty($this->request->data)){
  59. $this->request->data['User']['password'] = AuthComponent::password($this->request->data['User']['password']);
  60. $sprawdz = $this->User->find('first',array('conditions'=>array('User.username'=>$this->request->data['User']['username'],'User.password'=>$this->request->data['User']['password'])));
  61. echo debug($sprawdz);
  62. if(!empty($sprawdz)){
  63. if($this->Auth->login()){
  64. $this->redirect('/');
  65. echo debug('you are log in!') ;
  66. }
  67. }
  68. else {
  69. $this->Session->setFlash('Invalid username or password');
  70. }
  71. }
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement