diff options
author | Eric Davis <edavis@littlestreamsoftware.com> | 2009-02-11 19:07:12 +0000 |
---|---|---|
committer | Eric Davis <edavis@littlestreamsoftware.com> | 2009-02-11 19:07:12 +0000 |
commit | 0310f43126ac8a8a7e14c8c3a09118b34ed6ff2f (patch) | |
tree | faa9815334b14724c0ea4c9b9bf0a7f2077209a4 /app/models | |
parent | 896e64b759aee595766969799bb2169e65a46cd6 (diff) | |
download | redmine-0310f43126ac8a8a7e14c8c3a09118b34ed6ff2f.tar.gz redmine-0310f43126ac8a8a7e14c8c3a09118b34ed6ff2f.zip |
Hooked up on the fly OpenID user creation.
* Use OpenID registration fields for the user.
* Generate a random password when a user is created.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2443 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/user.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/app/models/user.rb b/app/models/user.rb index 0005c85d1..b35c1a815 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -138,6 +138,18 @@ class User < ActiveRecord::Base def check_password?(clear_password) User.hash_password(clear_password) == self.hashed_password end + + # Generate and set a random password. Useful for automated user creation + # Based on Token#generate_token_value + # + def random_password + chars = ("a".."z").to_a + ("A".."Z").to_a + ("0".."9").to_a + password = '' + 40.times { |i| password << chars[rand(chars.size-1)] } + self.password = password + self.password_confirmation = password + self + end def pref self.preference ||= UserPreference.new(:user => self) |