Closed deadmantfa closed 9 months ago
Context Had same problem with 2amigos/yii2-usuario version 1.6.1 and a custom User model that extends the yii2-usuario one.
Problem Found out the problem is syntactical and it's actually in:
vendor/2amigos/yii2-usuario/src/User/Validator/TwoFactorEmailValidator.php line 114
at this line the trait method make()
is used, passing the class we want to make as the first argument, and the $this->user
as a second argument; and the problem is here!
The trait method make()
uses the yii\di\Container::get()
method, which accepts an array as a second parameter. It does not throw an exception probably because the User object is silently cast in array, so the argument is still formally valid.
Solution
Coming back to TwoFactorEmailValidator.php line 114
, if instead of
return $this->make(TwoFactorEmailCodeGeneratorService::class, $this->user)->run();
you use
return $this->make(TwoFactorEmailCodeGeneratorService::class, [$this->user])->run();
then everything starts to work.
Hope to have been useful, I will submit a pull request if someone else doesn't beat me on time.
Live long and prosper \\//_
There is a PR already there #519 with the fixes its not merged yet
Thank you deadmantfa, didn't see it before doing mine. For readers:
PR merged, should fix this issue
What steps will reproduce the problem?
Enable Two-Factor Email. Logout. Try Loging in - Error Message
What is the expected result?
Email to be sent with the code
What do you get instead?
Error message - Unable to send email