function login() { if (isset($this->request['login'])) { $password = sha1($this->request['password']); $appel = new User(); $req = $appel->finduser($this->request['login'], $password); if (!empty($req)) { $this->Session->write('User', $req); } } else { $this->render('login', 'User'); } if ($this->Session->isLogged()) { if ($this->Session->user('role') == 'admin') { $this->render('edit', 'User', 'admin'); } else { $this->redirect(''); } } }