function register()
{
$this->set('username_error', 'Username must be between 6 and 40 characters.');
{
if ($this->User->validates($this->data))
{
if ($this->User->findByUsername($this->data['User']['username']))
{
$this->User->invalidate('username');
$this->set('username_error', 'User already exists.');
} else {
$this->
data['User']['password'] =
md5($this->
data['User']['password']);
if ($this->User->save($this->data))
{
$aro = new Aro();
$aro->create($this->User->id, 'User', $this->data['User']['username']);
$this->Session->write('user', $this->data['User']['username']);
$this->redirect('/users/cp');
} else {
$this->flash('There was a problem saving this information', '/users/register');
}
}
} else {
$this->validateErrors($this->User);
}
}
}