Created
May 14, 2024 16:14
-
-
Save fractaledmind/5086a291e215a871275cb18c890b59a5 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