Closed larry-tx closed 5 years ago
Seems to be something wrong with your mailer configuration.
Note that enableEmailConfirmation
set to false
will still sent the e-mail to user about creating an user. Its just not requiring the conformation click.
I have just installed a clean yii2-advanded app from scratch, installed and configured the usuario extension and it seems to work just fine.
I'm so happy that worked for you. Now, just how often does anyone ever actually put into production a Website that is perfectly clean and devoid of anything but one extension. That just isn't real. The real world doesn't work like that. A well-designed extension works in an environment with multiple other extensions, many, many, many models and their associated controllers and views, a layout that is different than what is shipped from Github, and so on. A well-designed extension insulates itself from other extensions.
@LarryTX , I have 20+ apps with yii2-usuario in production and I did not had any problems.
And I have to agree with @TonisOrmisson, most likely this error is generated by the mailer configuration. Please disable the mail sending functionality and try again (and if this does not help, please post your config files also).
@LarryTX thank you very much for such detailed issued. Usuario
is actually not doing anything with Mailer
but using the mailer
component that is already configured on your Yii application. The only thing it overrides (in case the developer requires to do so as we did in many apps) is the mail parameters (https://github.com/2amigos/yii2-usuario/blob/master/src/User/Service/MailService.php)
The MailService
is instantiated by Yii2's di
at all times, thus, injecting dynamically the mailer by using getMailer()
(https://github.com/2amigos/yii2-usuario/blob/master/src/User/Factory/MailFactory.php#L136).
That error reminds me an issue I had when configuring the mailer
component Yii, as the mailer uses a transport
and is the transport the one that dynamically uses "set" . $config
to the SwiftMailer's transport. So the component must be set as:
'components' => [
'mailer' => [
'class' => 'yii\swiftmailer\Mailer',
'transport' => [
'class' => 'Swift_SmtpTransport',
'host' => 'localhost',
'username' => 'username',
'password' => 'password',
'port' => '587',
'encryption' => 'tls',
],
],
// ...
],
The problem I had was that I did this:
'components' => [
'mailer' => [
'class' => 'yii\swiftmailer\Mailer',
'host' => 'localhost', // <--- That was my mistake
'transport' => [
'class' => 'Swift_SmtpTransport',
'username' => 'username',
'password' => 'password',
'port' => '587',
'encryption' => 'tls',
],
],
// ...
],
Do you mind checking if that was the issue? Thanks in advance
Closed by no reaction to the last answer. Hope that was the issue and the solution.
What steps will reproduce the problem?
Installed the extension exactly as described in the documentation. Specifically,
composer require 2amigos/yii2-usuario:~1.0
yii migrate --migrationPath=@yii/rbac/migrations
. This picked up the migrations needed for yii2-usario as well as those needed by RBAC.<backend URL for my app>/user/registration/register.
What is the expected result?
A record would be entered in the user table of the database.
What do you get instead?
The following message was displayed: User could not be registered. I did find the following information in backend/runtime/app.log:
Since the very cryptic error message (User could not be registered) was the only information that I had to go on, I have no idea whether the SwiftMailer error would be sufficient to prevent registration when i had disabled email confirmation.
It is very clear that whoever assembled this extension had little understanding of the Yii2 advanced template. I had to do a great deal of experimentation to get it work at all in the advanced template. Your documentation should be amended to reflect the following:
Anyway, I'm still completely stuck after all this work without the ability to make use of any of the functionality of this extension. Hope someone who understands the advanced template, in use by a majority of those developing in Yii2, can help resolve this show-stopping enigma.