Witajcie!
Męczę się już 2h i rozkłądam ręce...
Chcę zrobić osobną(inną) stronę logowania bez wykorzystania template'u i tu pojawia się problem.
początek kontrolera:
class Controller_Dziennik extends Controller_Base
{
public $template= 'dziennik/template';
...
Strona główna, rejestracja, i inne dynamczne podstrony wykorzstują coś takiego:
public function action_index()
{
$this->template->title = 'Dashboard';
$this->template->content = View::forge('dziennik/dashboard');
}
Logowanie jest ciut bardziej skomplikowane:
public function action_logowanie()
{
// Already logged in
Auth::check() and Response::redirect('dziennik');
$val = Validation::forge();
if (Input::method() == 'POST')
{
$val->add('email', 'Email or Username')
->add_rule('required');
$val->add('password', 'Password')
->add_rule('required');
if ($val->run())
{
$auth = Auth::instance();
// check the credentials. This assumes that you have the previous table created
if (Auth::check() or $auth->login(Input::post('email'), Input::post('password')))
{
// credentials ok, go right in
if (Config::get('auth.driver', 'Simpleauth') == 'Ormauth')
{
$current_user = Model\Auth_User::find_by_username(Auth::get_screen_name());
}
else
{
$current_user = Model_User::find_by_username(Auth::get_screen_name());
}
Session::set_flash('success', e('Welcome, '.$current_user->username));
Response::redirect('dziennik');
}
else
{
$this->logowanie->set_global('login_error', 'Błędny login lub hasło!');
}
}
}
$this->logowanie->title = 'Logowanie';
$this->logowanie->content = View
::forge('dziennik/logowanie', array('val' => $val), false); #Return View::forge('dziennik/logowanie');
}
I tu pojawia się problem - nie chcę w logowaniu szablonu pozostałych podstron, natomiast chcę zachować możliwość przekazwyania statusu logowania do szablonu.
Chamskie obejście: public $logowanie= 'dziennik/logowanie'; nie działa(Attempt to assign property of non-object)
Mam nadzieję, że zrozumieliście ten chaos, z góry wielkie dzięki za pomoc!
PS: Dopiero zaczynam przygodę z obiektówką więc jeśli jest to błachy problem to przepraszam za niewiedzę (IMG:
style_emoticons/default/smile.gif)
Ten post edytował filipsiu 9.07.2014, 11:23:42