Hi, thanks for your reply.
Here is my form under the login/index/phtml
<form id="login-form" action="login/start" method="post" role="form" style="display: block;">
<div class="form-group">
<input type="text" name="username" id="username" tabindex="1" class="form-control" placeholder="Username" value="">
</div>
<div class="form-group">
<input type="password" name="password" id="password" tabindex="2" class="form-control" placeholder="Password">
</div>
<div class="form-group text-center">
<input type="checkbox" tabindex="3" class="" name="remember" id="remember">
<label for="remember"> Remember Me</label>
</div>
<div class="form-group">
<div class="row">
<div class="col-sm-6 col-sm-offset-3">
<input type="submit" name="login-submit" id="login-submit" tabindex="4" class="form-control btn btn-login" value="Log In">
</div>
</div>
</div>
<div class="form-group">
<div class="row">
<div class="col-lg-12">
<div class="text-center">
<a href="https://phpoll.com/recover" tabindex="5" class="forgot-password">Forgot Password?</a>
</div>
</div>
</div>
</div>
</form>
This is my login controller:
public function indexAction()
{
//Inserto los assets de los CSS remotos y locales
$this->assets
->addCss('https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css',false)
->addCss('css/estilos.css');
//Inserto los assets de los javascript remotos y locales
$this->assets
->addJs('https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js',false)
->addJs('https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js',false)
->addJs('js/main.js');
}
public function startAction(){
//Inserto los assets de los CSS remotos y locales
$this->assets
->addCss('https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css',false)
->addCss('css/estilos.css');
//Inserto los assets de los javascript remotos y locales
$this->assets
->addJs('https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js',false)
->addJs('https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js',false)
->addJs('js/main.js');
if ($this->request->isPost()) {
// Get the data from the user
$email = $this->request->getPost('username');
$password = $this->request->getPost('password');
$user = Users::findFirstByemail($email);
if ($user) {
if ($this->security->checkHash($password, $user->password)){
$this->_registerSession($user);
$this->flash->success(
'Welcome ' . $user->name
);
}
else {
$this->security->hash(rand());
$this->flashSession->error("Wrong email/password");
return $this->view->pick("login");
/*$this->flash->error(
'Wrong email/password'
);*/
}
}
else {
$this->security->hash(rand());
$this->flash->error(
'Wrong email/password'
);
}
}
}
private function _registerSession($user){
$this->session->set(
'auth',
[
'id' => $user->id,
'name' => $user->name,
]
);
}