Use correct User model if overwritten in config

Two factor authentication doesn't work if the User model has been changed in the config from the modules own model class. This fix gets the correct User model from the class map.
This commit is contained in:
Jussi Aho
2023-02-23 12:49:07 +02:00
committed by GitHub
parent cdbe7628f0
commit f22148660b

View File

@ -221,9 +221,10 @@ class SecurityController extends Controller
$validators = $module->twoFactorAuthenticationValidators; $validators = $module->twoFactorAuthenticationValidators;
$credentials = Yii::$app->session->get('credentials'); $credentials = Yii::$app->session->get('credentials');
$login = $credentials['login']; $login = $credentials['login'];
$user = User::findOne(['email' => $login]); $userModel = $this->getClassMap()->get(User::class);
$user = $userModel::findOne(['email' => $login]);
if ($user == null) { if ($user == null) {
$user = User::findOne(['username' => $login]); $user = $userModel::findOne(['username' => $login]);
} }
$tfType = $user->getAuthTfType(); $tfType = $user->getAuthTfType();