Can't login with CakePHP's Auth login (Invalid password or username)

2014-03-17 Thread Bruno Messias
Hi guys. 

I'm using cakephp 2.x and can't seem to make Auth->login() work.

app/Controller/AppController.php

class AppController extends Controller {

   // sitema de autentificacao simples 
http://book.cakephp.org/2.0/en/tutorials-and-examples/blog-auth-example/auth.html
   
public $components = array(
'Session',
'Auth' => array(
'loginAction' => array('controller'=>'eleitores', 
'action'=>'login'),
'loginRedirect' => array('controller'=>'linhas', 
'action'=>'index'),
'logoutRedirect' => array('controller'=>'pages', 
'action'=>'display', 'index'),
'authorize' => array('Controller'),
'authenticate' => array(
'Form' => array(
'userModel' => 'Eleitore',
'scope' => array('Eleitore.id' => 1)
)
),
'authError' => 'Você não possui autorização para acessar esta 
página!'
)
);
 
public function beforeFilter() {
$this->Auth->allow();   
}

...
app/Controller/EleitoresController.php

Auth->userModel = 'GroupUser';
if ($this->request->is('post')) {
 if ($this->Auth->login()) {
return $this->redirect($this->Auth->redirect());
 }
 $this->Session->setFlash(__('Invalid username or password, 
try again'));
}
}

app/View/Eleitores/login.ctp


Session->flash('auth'); ?>
Form->create('Eleitore'); ?>




Form->input('username');
echo $this->Form->input('password');
?>

Form->end(__('Login')); ?>



-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: Staying DRY best practice?

2014-03-17 Thread designv...@gmail.com
Check out the CRUD plugin: https://github.com/FriendsOfCake/crud

On Sunday, 16 March 2014 12:39:58 UTC, Harold Putman wrote:
>
> I've noticed that my controller methods and views for admin_edit, 
> admin_add, edit, add have a lot of overlapping code. What is the best 
> practice for organizing my code so there is not so much duplication. Do you 
> create an Element for the body of the editing form? Share views between 
> admin and normal routes?
>
> I'm curious how other people are handling this in Cake 2.x 
>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.