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

Commit

Permalink
lib/tasks: added a task to create users
Browse files Browse the repository at this point in the history
See issues #179 and #283

Signed-off-by: Miquel Sabaté Solà <msabate@suse.com>
  • Loading branch information
mssola committed Nov 13, 2015
1 parent 25cba14 commit 79bac5c
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 79bac5c

Please sign in to comment.