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

Commit

Permalink
Merge pull request #569 from mssola/rake_users
Browse files Browse the repository at this point in the history
lib/tasks: added a task to create users
  • Loading branch information
mssola committed Nov 16, 2015
2 parents b40aae1 + 79bac5c commit 2952d5d
Showing 1 changed file with 17 additions and 1 deletion.
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

0 comments on commit 2952d5d

Please sign in to comment.