i'm making a online test web application, these are the controllers
- Faculties
- Students
- Tests
- Notes
- Questions
- Answers
- TestQuestions
- StudentResults
- StudentsTests
Note : students and faculties both have different logins
I'm trying to login in Faculties Controller, i have load Auth component in App controller,
When I'm trying to login, it shows an error "username or password is incorrect"
This is the App controller
$this->loadComponent('Auth', [
'loginAction'=> [
'controller'=>'Faculties',
'action'=> 'login',
],
'authenticate' => [
'Form' => [
'userModel' => 'Faculties',
'fields' => ['username' => 'email', 'password' => 'password'],
]
],
'loginRedirect' => [
'controller' => 'Faculties',
'action' => 'index'
]
]);
This is the login function in Faculties controller
public function login()
{
if ($this->request->is('post'))
{
debug($this->request->getData());
debug($this->Auth->identify());
$faculty = $this->Auth->identify();
if ($faculty)
{
$this->Auth-setUser($faculty);
return $this->redirect($this->Auth->redirectUrl());
}
$this->Flash->error('Your username or password is incorrect');
}
}
view of login
<h1>Login</h1>
<?= $this->Form->create() ?>
<?= $this->Form->control('email') ?>
<?= $this->Form->control('password') ?>
<?= $this->Form->submit('Login') ?>
<?= $this->Form->end() ?>
faculties schema
CREATE TABLE IF NOT EXISTS `mydb`.`faculties` (
`id` INT NOT NULL AUTO_INCREMENT COMMENT '',
`email` VARCHAR(45) NOT NULL COMMENT '',
`password` VARCHAR(45) NOT NULL COMMENT '',
`first_name` VARCHAR(45) NOT NULL COMMENT '',
`last_name` VARCHAR(45) NULL COMMENT '',
`profile_pic` VARBINARY(8000) NULL COMMENT '',
`mobile_no` INT(10) NOT NULL COMMENT '',
`college` VARCHAR(100) NULL COMMENT '',
`department` VARCHAR(100) NULL COMMENT '',
`subjects` TEXT NULL COMMENT '',
`created` DATETIME NULL COMMENT '',
`modified` DATETIME NULL COMMENT '',
PRIMARY KEY (`id`) COMMENT '')
ENGINE = InnoDB
please help whats wrong in the code
facultiesdatabase schema ? - tarikul05password VARCHAR(45)length45is not enough increase it and try again by registering - tarikul05