Closed stevegrossi closed 2 years ago
I've added a third option above that I think would meet this need simply and flexibly with no additional changes to scim_rails 🙏🏻
Closing this as the third option (which requires no changes to this library) has worked nicely for us.
The Problem
At Lessonly, we have a need to run other code after a user is created or updated via scim_rails. For instance, when a user is created via SCIM we might want to send them a welcome email. Currently, this does not appear possible without an
after_create
callback on theUser
model, which is inadvisable because there are other situations in which we don't want to send the welcome email after a user is created.Potential Solutions
Option A: an "after" callback in scim_rails
For example, we might add a configuration setting like so:
This would be run (if configured) after the
ScimUsersController#create
controller action. It would likely make sense to add similar callbacks forafter_user_update
, etc.Option B: monkey-patching (with no changes to scim_rails)
Though I suppose monkey-patching that controller would also be an option for end-users if there are reasons not to add this functionality to scim_rails itself, e.g.
however that would be more brittle than supporting this functionality natively in scim_rails.
Option C: Use a custom scim_users_model with callbacks
A conversation with @emmoistner prompted what I think is an even better solution than the above which would require no changes to scim_rails. Since
config.scim_users_model
is already configurable, a solution for adding behavior on create/update that we want to keep local to SCIM would be a custom superclass, e.g.