nineinchnick / yii2-usr

Yii framework module for user authentication, password reset, registration and profile updating. A port of yii-usr to Yii Framework 2.0.
http://demo2.niix.pl
MIT License
39 stars 8 forks source link

Use Yii event system for eg. registration #16

Open schmunk42 opened 10 years ago

schmunk42 commented 10 years ago

It would be nice, if you could fire some module events, eg. when a user registers, get approved or requests a new password.

The main advantage of this approach would be, that you could easily plug-in custom application code, when a certain event happens. Even sending the e-mail could be implemented with a callback, which would give you great flexibility.

But also notifying an internal service (eg. create a LDAP account), when a user has been approved could be a nice use-case.

nineinchnick commented 10 years ago

The module uses the User class to perform all such tasks. This class implements all required interfaces. This is where all the events should fire from. Since I don't want to enforce using any base class for this, there isn't really a good way to implement this. And since the User class is provided by the app (developer), not by the module, it could perform any number of additional tasks.

This could be however done in the ExampleUser class bundled with the extension. I wonder if it isn't going a bit too far in the future, maybe some more user feedback is required?

Sending email could be optional and/or moved to the User class as well.

schmunk42 commented 10 years ago

That sounds nice so far. One important thing to add here: Do not enforce a specific web-user class, like https://github.com/mishamx/yii-user did it. But as far as I understood you, this is not the case, I just want to address the pain points I had with Yii 1 extensions.

nineinchnick commented 10 years ago

That's the main idea behind my extension, to allow easy integration into existing projects by a well-defined interface.

Thanks a lot for your input, it's really motivating :smile: This is going to be a productive weekend.