-
-
Save dimerman/5782ad8f5ab75ca1a659986ac87b6370 to your computer and use it in GitHub Desktop.
Example of simple file to centralize User management
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
users_file = Rails.root.join('storage', 'users.yml.erb') | |
if File.exist? users_file | |
users = YAML.load(ERB.new(File.read(users_file)).result) | |
User.insert_all( | |
users.map { |user| user.except("password") }, | |
unique_by: :username | |
) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<% | |
def digest(username, password) | |
ActionController::HttpAuthentication::Digest.ha1( | |
{ | |
username: username, | |
realm: Rails.application.credentials.auth_realm | |
}, | |
password | |
) | |
end | |
%> | |
--- | |
- username: spm | |
email: [email protected] | |
password: 'mypassword' | |
password_digest: <%= digest("spm", "mypassword") %> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment