Hi so how do you do it in kohana 3.3 and kostache?
Form
<form method="POST" action="user/login">
<input type="text" name="email" />
<input type="passowrd" name="password" />
</form>
Controller
public function action_login()
{
$user = Auth::instance()->login($this->request->post('email'),$this->request->post('password'));
if($user)
{
$view = Kostache_Layout::factory()
$layout = new View_Pages_User_Info();
$this->response->body($this->view->render($layout));
}
else
{
$this->show_error_page();
}
}
Class View
class View_Pages_User_Info
{
public $title= "Profile";
}
Mustache Template
<p> This is the Profile Page</p>
So far so good, I'm now in the profile page but the url is
localhost/kohana_app/user/login
instead of
localhost/kohana_app/user/profile
I know I can change the action_login
to action_profile
to match the url and the title of the page but is there any other way to do this?
Forget about a body for the response if the login was succesful and redirect to the profile page.
Read up on Post/Redirect/Get.
Example route(s) as requested
Personally I like to send my users to a dashboard, which can be(come) different from viewing your own profile.
This is just A way of doing it.