Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class UsersController extends AppController {
- var $name = 'Users';
- var $components = array('Auth', 'Acl');
- function beforeFilter(){
- //parent::beforeFilter();
- $this->Auth->loginError = "asdad!";
- $this->Auth->authError = "sdsd !.";
- App::uses('CakeEmail', 'Network/Email');
- $this->Auth->userModel = 'User';
- $this->Auth->allow('login','register','login','step2','TakeId','kontakt');
- }
- function login(){
- if(!empty($this->data)){
- $this->request->data['User']['password'] = AuthComponent::password($this->request->data['User']['password']);
- $sprawdz = $this->User->find('first',array('conditions'=>array('User.username'=>$this->request->data['User']['username'],'User.password'=>$this->request->data['User']['password'])));
- echo debug($sprawdz);
- if(!empty($sprawdz)){
- if($this->Auth->login($this->request->data)){
- $this->redirect('/');
- echo debug('you are log in!') ;
- }
- }
- else {
- $this->User->invalidate('username', 'mistake!');
- }
- }
- }
- function logout(){
- $this->Auth->logout();
- $this->redirect('/');
- }
- }
- <?php echo $this->Session->flash('auth'); ?>
- <?php echo $this->Form->create('User'); ?>
- <fieldset>
- <?php echo $this->Form->input('username');
- echo $this->Form->input('password'); ?>
- </fieldset>
- <?php echo $this->Form->end(__('Log in')); ?>
- function login(){
- if ($this->request->is('post')) {
- if ($this->Auth->login()) {
- $this->Session->setFlash('You have successfully logged in the system');
- return $this->redirect('/');
- }
- $this->Session->setFlash(__('Invalid username or password, try again [warning]'));
- }
- }
- function login(){
- if(!empty($this->request->data)){
- $this->request->data['User']['password'] = AuthComponent::password($this->request->data['User']['password']);
- $sprawdz = $this->User->find('first',array('conditions'=>array('User.username'=>$this->request->data['User']['username'],'User.password'=>$this->request->data['User']['password'])));
- echo debug($sprawdz);
- if(!empty($sprawdz)){
- if($this->Auth->login()){
- $this->redirect('/');
- echo debug('you are log in!') ;
- }
- }
- else {
- $this->Session->setFlash('Invalid username or password');
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement