Mam taką rejestrację, która działa poprawnie:
class Controller_Rejestracja extends Controller_Index {
function action_index(){
$this->template->content = new View("rejestracja");
if($_POST){
# Instancja nowego usera
$user = ORM::factory('user');
# Walidacja
if($user->values($_POST)->check())
{
# Uzupełniam dane
$user->key = md5($user->password);
# Zapisuje
if($user->save()){
# Wysyłam e-mail aktywacyjny
Mailer
::factory('mail')->send_welcome(array( 'username' => $user->username,
'email' => $user->email,
'key' => $user->key
));
$this->template->content->is_registered = true;
}
} else {
# Błędnie wypełniony formularz
$this->template->content->errors = $user->validate()->errors("user");
}
}
}
I takie logowanie, które działa nie poprawnie ($status zwraca zawsze false):
class Controller_Zaloguj extends Controller_Index {
function action_index(){
$this->template->content = new View("zaloguj");
if(Auth::instance()->logged_in()!= 0){
Request::instance()->redirect('account/myaccount');
}
if($_POST){
$user = ORM::factory('user');
$status = $user->login($_POST);
if($status){
$this->request->redirect('/xxx/');
} else {
$this->session->set('error_auth',true);
$this->request->redirect("http://localhost/xxx/zaloguj/");
}
}
$this->template->content->is_error = $this->session->get('error_auth');
$this->session->delete('error_auth');
}
}
Co mogę robić źle lub o czym zapomniałem? :/