From 79bac5c4f54b758831c867fc08b0b567418cae7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miquel=20Sabat=C3=A9=20Sol=C3=A0?= Date: Fri, 13 Nov 2015 15:43:44 +0100 Subject: [PATCH] lib/tasks: added a task to create users MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See issues #179 and #283 Signed-off-by: Miquel Sabaté Solà --- lib/tasks/portus.rake | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/tasks/portus.rake b/lib/tasks/portus.rake index 7a1a0525a..79e2fd3a8 100644 --- a/lib/tasks/portus.rake +++ b/lib/tasks/portus.rake @@ -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] @@ -33,5 +50,4 @@ namespace :portus do exit(-3) end end - end