rainlab / user-plugin

Front-end user management.
Other
113 stars 154 forks source link

Component functions for REST API and GraphQL #564

Open xmelic8 opened 3 months ago

xmelic8 commented 3 months ago

Transitioning to Laravel Auth is great. However, implementing functions directly into components is unfortunate. These functions can't be used when creating REST API and GraphQL interfaces, which leads to unnecessary duplication of logic.

Wouldn't it be better to separate the logic common to components and APIs into a separate class? For example, password reset requests use PasswordBroker. The User class implements a trait with the function sendPasswordResetNotification(). Although there is a setUrlForPasswordReset() function available, I don't see a way to call it if I want to use REST API and don't have a resetPassword component in the CMS. I would also prefer to send the email through the queue. But how can I override the sendPasswordResetNotification function in this trait?

daftspunk commented 3 months ago

Good points, @xmelic8. Thank you!

xmelic8 commented 3 months ago

Is there a plan to implement these changes in the near future versions? Or should I create a fork, make the changes, and submit pull requests for testing?

daftspunk commented 3 months ago

Yes, please. Then we can make a new release for it alongside #565