Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[#40] Added rake task for anonymizing the users table.

  • Loading branch information...
commit 67ebc783f0ce5b389b73d891e5dea5f22f6cea3e 1 parent e2c10df
@zk authored
Showing with 29 additions and 0 deletions.
  1. +29 −0 Rakefile
View
29 Rakefile
@@ -9,8 +9,15 @@ require 'rake/rdoctask'
require 'tasks/rails'
+require 'digest/sha1'
+
puts ENV['RAILS_ENV']
+
+def sha1(s)
+ Digest::SHA1.hexdigest(s) if s
+end
+
if ENV['RAILS_ENV'] != 'production'
require 'rcov/rcovtask'
@@ -35,4 +42,26 @@ if ENV['RAILS_ENV'] != 'production'
task :coverage => "test:coverage:#{target}"
end
end
+
+ desc "Anonymize user table."
+ namespace :db do
+ task :clean => :environment do
+
+ # Need to do this with reflection
+ User.find_each do |u|
+ u.login = sha1 u.login
+ u.email = "#{sha1(u.email)}@clojuredocs.org"
+ u.crypted_password = sha1 u.crypted_password
+ u.password_salt = sha1 u.password_salt
+ u.persistence_token = sha1 u.persistence_token
+ u.current_login_ip = sha1 u.current_login_ip
+ u.last_login_ip = sha1 u.last_login_ip
+ u.openid_identifier = nil
+ u.save(false)
+ end
+
+ end
+ end
+
end
+
Please sign in to comment.
Something went wrong with that request. Please try again.