diff options
author | Thomas Kjeldahl Nilsson <thomas@kjeldahlnilsson.net> | 2012-04-16 08:19:28 (GMT) |
---|---|---|
committer | Thomas Kjeldahl Nilsson <thomas@kjeldahlnilsson.net> | 2012-04-26 18:54:18 (GMT) |
commit | 2524188421981ffae7311b984d042d1994505beb (patch) | |
tree | 6267d8387358b4670fcdd5e9ef11b655d69e6aa3 /script | |
parent | 086f65c15d1a4320fe64f0dc4b8b115f09b6ec3f (diff) |
Improved suspend user feature.
Suspend user logic is moved into new module Gitorious::UserAdministration,
and expanded to clear out ssh keys, cull current session and remove
users committerships and team memberships. All this is reported back in the
web UI after suspension is done. Also added a suspend_user script which takes
the account email address and performs the same suspend operation as the
web UI button.
Also added helper functions to detect of potential orphaned teams, admin-less
teams, which can be acted upon in custom automated workflows where one needs
to ensure that no projects or teams are orphaned when the owner/sole admin
is suspended.
Diffstat (limited to 'script')
-rwxr-xr-x | script/create_user | 21 | ||||
-rwxr-xr-x | script/suspend_user | 40 |
2 files changed, 61 insertions, 0 deletions
diff --git a/script/create_user b/script/create_user new file mode 100755 index 0000000..4d6ed8f --- /dev/null +++ b/script/create_user @@ -0,0 +1,21 @@ +#!/usr/bin/env ruby +require File.dirname(__FILE__)+'/../config/environment' +ActionMailer::Base.raise_delivery_errors = false +ActionMailer::Base.delivery_method = :test + +puts "Type in users login: " +login = gets.strip + +puts "Type in users e-mail: " +email = gets.strip +puts "Type in users password: " +password = gets.strip + +user = User.new(:email => email, :terms_of_use => '1') +user.password = password +user.password_confirmation = password +user.login = login + +user.save! +user.activate +puts "User '#{login}' created successfully." diff --git a/script/suspend_user b/script/suspend_user new file mode 100755 index 0000000..e3c399f --- /dev/null +++ b/script/suspend_user @@ -0,0 +1,40 @@ +#!/usr/bin/env ruby + +def print_usage + puts "" + puts "Usage: suspend_user USER_EMAIL_ADDRESS" + puts "" + puts "Suspends specified Gitorious user, revoking all access to web UI and git operations." + puts "" + puts "Account is suspended, can no longer log in and loses current browser session." + puts "SSH keys are revoked, user no longer able to push, pull, clone git repositories" + puts "Committerships and team memberships are removed." + puts "" +end + +puts "---Loading Gitorious environment---" +require File.dirname(__FILE__)+'/../config/environment' +puts "---Done loading Gitorious environment---\n\n" + +def find_user(user_email) + user = User.find_by_email(user_email) + if !user + puts "No Gitorious account with email '#{user_email}', exiting..." + exit 1 + end + return user +end + +include Gitorious::UserAdministration + +if !ARGV[0] + print_usage + exit 1 +end + +user_email = ARGV[0] + +puts "Suspending '#{user_email}'..." + +user = find_user(user_email) +puts suspend_user(user) |