aboutsummaryrefslogtreecommitdiffstats
path: root/app/models/user.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/user.rb')
-rw-r--r--app/models/user.rb21
1 files changed, 20 insertions, 1 deletions
diff --git a/app/models/user.rb b/app/models/user.rb
index cb0b6b867..aa7014a54 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -21,7 +21,7 @@
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: user.rb,v 1.56 2008-05-21 10:51:24 francis Exp $
+# $Id: user.rb,v 1.57 2008-07-08 09:41:04 francis Exp $
require 'digest/sha1'
@@ -133,6 +133,25 @@ class User < ActiveRecord::Base
return self.name + " <" + self.email + ">"
end
+ # The "internal admin" is a special user for internal use.
+ def User.internal_admin_user
+ contact_email = MySociety::Config.get("CONTACT_EMAIL", 'contact@localhost')
+ u = User.find_by_email(contact_email)
+ if u.nil?
+ password = PostRedirect.generate_random_token
+ u = User.new(
+ :name => 'Internal admin user',
+ :email => contact_email,
+ :password => password,
+ :password_confirmation => password
+ )
+ u.save!
+ end
+
+ return u
+ end
+
+
private
def self.encrypted_password(password, salt)