-
Notifications
You must be signed in to change notification settings - Fork 153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to make config dynamic #62
Comments
Can you give me a made up code example of what you would like to be able to do? |
class Manager < ActiveRecord::Base
devise :database_authenticatable, :registerable,
:recoverable, :trackable,
:confirmable, :lockable,
:secure_validatable
belongs_to :team
# Override password_length enforced by secure_validatable
def password_length
team.password_length | # return value from the devise config file
end
def password_complexity
team.password_complexity | # return value from the devise config file
end
# Have similar overrides for other module rules etc
end |
On the surface this seems like it could work, but I suspect what is happening is that those methods are being evaluated at the time the class is loaded and never again after that. I'll dig into it some more and see if we can verify this and modify this so that it can be a proc or something. |
Is there any way that something like this could make its way into the gem? I have a similar requirement where I have customers with sets of users that have differing IT policies on things like password complexity requirements, etc. |
Any updates on this? |
Hey guyz whats the status for this task |
Hey, I could also make use of this. Any updates or in between solutions available? |
Chipping away at this. Will be making some smaller PRs over the next few days hopefully. |
* Refactor tests for SecureValidatable module While working on #62, I noticed that there were a lot of edge cases that either weren't tested at all or did not consider all cases. I wanted to address this issue before finalizing my changes so that I have greater confidence that the changes do not break existing functionality in the module. This commit changes the following: * Removes the unnecessary devise modules from the User class so that we can be sure only functionality related to this module is being tested. * Removes a bunch of save commands, as writing to the DB slows tests down and most of the functionality could be tested without that. * Cleans up language of test descriptions. * Adds consistency to emails, passwords, and formatting for asserts. This commit adds the following tests: * Allow email to be blank if email is not required * Fail if updating email from non-blank to blank * Fail if password is blank on creation * Fail if password is updated to blank * Fail if password_confirmation does not match password or is blank * Allow password_confirmation to be skipped * Fail if new password equals existing password * Fail if module is included in a class that doesn't support the validates API This used #63 as a starting point. Co-authored-by: Kevin Olbrich <kevin.olbrich@gmail.com>
This will be released in |
Wondering how to best make the config attributes dynamic per instance of a model.
Example: for a given Model which belongs to a specific Organization might have different password validation requirements or password expiry length.
Overriding password_complexity, password_length or other methods in the Model doesn't seem to do anything. Any help here?
The text was updated successfully, but these errors were encountered: