Improved suspend user feature.
[gitorious:ksinkars-mainline.git] / script / suspend_user
1 #!/usr/bin/env ruby
2
3 def print_usage
4   puts ""
5   puts "Usage: suspend_user USER_EMAIL_ADDRESS"
6   puts ""
7   puts "Suspends specified Gitorious user, revoking all access to web UI and git operations."
8   puts ""
9   puts "Account is suspended, can no longer log in and loses current browser session."
10   puts "SSH keys are revoked, user no longer able to push, pull, clone git repositories"
11   puts "Committerships and team memberships are removed."
12   puts ""
13 end
14
15 puts "---Loading Gitorious environment---"
16 require File.dirname(__FILE__)+'/../config/environment'
17 puts "---Done loading Gitorious environment---\n\n"
18
19 def find_user(user_email)
20   user = User.find_by_email(user_email)
21   if !user
22     puts "No Gitorious account with email '#{user_email}', exiting..."
23     exit 1
24   end
25   return user
26 end
27
28 include Gitorious::UserAdministration
29
30 if !ARGV[0]
31   print_usage
32   exit 1
33 end
34
35 user_email = ARGV[0]
36
37 puts "Suspending '#{user_email}'..."
38
39 user = find_user(user_email)
40 puts suspend_user(user)