-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadmin_create.rb
78 lines (69 loc) · 2.03 KB
/
admin_create.rb
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
arg_username = ''
arg_email = ''
arg_first_name = ''
arg_last_name = ''
arg_pwd = ''
arg_pwd_conf = ''
puts '***********************'
puts 'Creating the admin user'
while arg_username == ''
puts
puts 'Enter the username of the new admin:'
arg_username = gets.chomp
end
while arg_email == ''
puts
puts 'Enter the email address of the new admin:'
arg_email = gets.chomp
end
while arg_first_name == ''
puts
puts 'Enter the first name of the new admin:'
arg_first_name = gets.chomp
end
while arg_last_name == ''
puts
puts 'Enter the last name of the new admin:'
arg_last_name = gets.chomp
end
while arg_pwd == ''
puts
puts
puts 'Using the same password for all of your accounts is risky.'
puts 'Limiting yourself to passwords that you can easily remember is risky.'
puts 'You should use a password management program like KeePassX'
puts '(http://www.keepassx.org/) to create much better passwords AND '
puts 'store them in encrypted form.'
puts
puts 'Enter the password of the new admin:'
arg_pwd = gets.chomp
end
while arg_pwd_conf == ''
puts
puts 'Confirm the password of the new admin:'
arg_pwd_conf = gets.chomp
end
puts
puts 'DEFAULT: no'
puts 'Do you wish to make this user a superadmin?'
puts "Enter 'Y' or 'y' to answer yes."
arg_super = gets.chomp
puts
if %w[Y y].include? arg_super
Admin.create!(username: arg_username, last_name: arg_last_name,
first_name: arg_first_name, email: arg_email,
password: arg_pwd, password_confirmation: arg_pwd_conf,
super: true, confirmed_at: Time.now)
puts 'Admin type: super'
else
Admin.create!(username: arg_username, last_name: arg_email,
first_name: arg_first_name, email: arg_email,
password: arg_pwd, password_confirmation: arg_pwd_conf,
super: false, confirmed_at: Time.now)
puts 'Admin type: regular'
end
puts "Username: #{arg_username}"
puts "First name: #{arg_first_name}"
puts "Last name: #{arg_last_name}"
puts "Email: #{arg_email}"
puts "Password: #{arg_pwd}"