-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathusers.rb
More file actions
39 lines (27 loc) · 947 Bytes
/
users.rb
File metadata and controls
39 lines (27 loc) · 947 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# users.rb
# Mirc pipeline processor
# This aids in creation of a MIRC users.xml
# Edit this file to create an instance variable @people
# that contains a Person with attributes
# username, password and an array of roles
require 'erb'
require 'csv'
require 'digest/md5'
b = binding
template_file = "users.erb"
# Available roles
# ['admin', 'author', 'publisher']
def hash_password(password)
require 'digest/md5'
password_hash = Digest::MD5.hexdigest("password goes here")
password_hash.hex
end
Person = Struct.new(:username, :roles, :hashed_password)
@people = []
CSV.foreach('./userlist.csv') do |row|
# Obviously this is an insecure password. include something real in your .csv file and pick the right row
# If you use LDAP - this password is ignored.
@people << Person.new(row[2].split("@")[0], ['author', 'department'], hash_password('password'))
end
template = ERB.new(File.read(template_file))
puts template.result(b)