No Problem.
class UsersController extends AppController {
var $components = array('Auth', 'Session');
public function beforeFilter() {
$this->Auth->allow(array('login'));
parent::beforeFilter();
}
public function login() {
}
public function logout() {
$this->Auth->logout();
}
/**
* index method
*
* @return void
*/
public function index() {
$this->User->recursive = 0;
$this->set('users', $this->paginate());
}
/**
* view method
*
* @param string $id
* @return void
*/
public function view($id = null) {
$this->User->id = $id;
if (!$this->User->exists()) {
throw new NotFoundException(__('Invalid user'));
}
$this->set('user', $this->User->read(null, $id));
}
/**
* add method
*
* @return void
*/
public function add() {
if ($this->request->is('post')) {
$this->User->create();
if ($this->User->save($this->request->data)) {
$this->Session->setFlash(__('The user has been
saved'));
$this->redirect(array('action' => 'index'));
} else {
$this->Session->setFlash(__('The user could not
be saved. Please,
try again.'));
}
}
}
/**
* edit method
*
* @param string $id
* @return void
*/
public function edit($id = null) {
$this->User->id = $id;
if (!$this->User->exists()) {
throw new NotFoundException(__('Invalid user'));
}
if ($this->request->is('post') || $this->request->is('put')) {
if ($this->User->save($this->request->data)) {
$this->Session->setFlash(__('The user has been
saved'));
$this->redirect(array('action' => 'index'));
} else {
$this->Session->setFlash(__('The user could not
be saved. Please,
try again.'));
}
} else {
$this->request->data = $this->User->read(null, $id);
}
}
/**
* delete method
*
* @param string $id
* @return void
*/
public function delete($id = null) {
if (!$this->request->is('post')) {
throw new MethodNotAllowedException();
}
$this->User->id = $id;
if (!$this->User->exists()) {
throw new NotFoundException(__('Invalid user'));
}
if ($this->User->delete()) {
$this->Session->setFlash(__('User deleted'));
$this->redirect(array('action'=>'index'));
}
$this->Session->setFlash(__('User was not deleted'));
$this->redirect(array('action' => 'index'));
}
}
login.ctp
<h2>Login</h2>
<div data-role="fieldcontain">
<?php echo $this->Form->create('User', array('action' => 'login')); ?
>
<?php echo $this->Form->input('username', array('label' =>
__('Benutzername'))); ?>
<?php echo $this->Form->input('password', array('label' =>
__('Passwort'))); ?>
<?php echo $this->Form->end(__('Login')); ?>
</div>
On 18 Nov., 10:48, Jeremy Burns | Class Outfit
<[email protected]> wrote:
> Fancy showing some code or shall we just guess?
>
> Jeremy Burns
> Class Outfit
>
> http://www.classoutfit.com
>
> On 18 Nov 2011, at 09:44, Gerrit wrote:
>
>
>
>
>
>
>
> > Hello everybody,
>
> > I've added the Auth-component, added the login-action, created a model
> > and created the login-view. And I've also created my user in the Users-
> > table with my hashed-password. Now the login don't work. When I click
> > the login-button I receive the login-page with no message and no
> > executed sql-statement.
>
> > What could be the reason?
>
> > Thanks!
>
> > --
> > Our newest site for the community: CakePHP Video
> > Tutorialshttp://tv.cakephp.org
> > Check out the new CakePHP Questions sitehttp://ask.cakephp.organd help
> > others with their CakePHP related questions.
>
> > To unsubscribe from this group, send email to
> > [email protected] For more options, visit this group
> > athttp://groups.google.com/group/cake-php
--
Our newest site for the community: CakePHP Video Tutorials
http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others
with their CakePHP related questions.
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at
http://groups.google.com/group/cake-php