Hello Gentlemen,
I am really tired of searching, searching a solution for my webApp. I have two login forms (email,password) for Tutor and for Student. details are populated from two tables called Tutor and Students. once i enter tutor login details it will load me the student profile page. student logins are fine, but tutor login was not okay. I added tutor php file into yiisoft/yii2/web and modify the components as well but still loading the student table details to me.
‘user’ => [
'identityClass' => 'app\models\Users',
'enableAutoLogin' => true,
],
'tutor' => [
'class' => 'yii\web\Tutor',
'identityClass' => 'app\models\Tutor',
'enableAutoLogin' => true,
],
Tutor Model
public static function findByEmail($email,$pass)
{
//find the specific user by their email in the DB
$found = Tutor::find()->where(['email' => $email])->one();
if(!empty($found))
{
//encript password for validation perpose
$encript = crypt($pass,'$6$rounds=1212$16charactersalt');
if($encript == $found->password)
{
//allow the user to login
Yii::$app->tutor->login($found);
}
else
{
die('invalid password');
}
}
else
{
die('invalid email address');
}
}[/color]