Sometime we need to customise some logic of devise, which usually done via inheritance of Devise::Passwords controller. However, the script would get injected because the class name is no longer Devise::PasswordsController
How?
This fix checks all the ancestors of the current controller and intersect with BLOCKED controller names, and block when there is positive count.
Alternatively, we could use superclass.name instead of class.ancestors.map(&:name), however this is limited to only 1 level of inheritance from Devise::PasswordsController
Why?
Sometime we need to customise some logic of devise, which usually done via inheritance of Devise::Passwords controller. However, the script would get injected because the class name is no longer
Devise::PasswordsController
How?
This fix checks all the ancestors of the current controller and intersect with BLOCKED controller names, and block when there is positive count.
Alternatively, we could use
superclass.name
instead ofclass.ancestors.map(&:name)
, however this is limited to only 1 level of inheritance fromDevise::PasswordsController