Skip to content
This repository has been archived by the owner on Apr 17, 2023. It is now read-only.

lib/tasks: added a task to create users #569

Merged
merged 1 commit into from
Nov 16, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion lib/tasks/portus.rake
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,23 @@ namespace :portus do
)
end

desc "Create a user"
task :create_user, [:username, :email, :password, :admin] => :environment do |_, args|
args.each do |k, v|
if v.empty?
puts "You have to provide a value for `#{k}'"
exit(-1)
end
end

User.create!(
username: args["username"],
password: args["password"],
email: args["email"],
admin: args["admin"]
)
end

desc "Give 'admin' role to a user"
task :make_admin, [:username] => [:environment] do |_, args|
unless args[:username]
Expand All @@ -33,5 +50,4 @@ namespace :portus do
exit(-3)
end
end

end