Commit 9132d309adda6d848b2b9cdb4d56dda3010f8b68
1 parent
6d92aa6d
Exists in
master
and in
4 other branches
Implementing automatic password creation.
Showing
1 changed file
with
8 additions
and
0 deletions
Show diff stats
app/models/user.rb
... | ... | @@ -53,6 +53,14 @@ class User < ActiveRecord::Base |
53 | 53 | scope :blocked, where(:blocked => true) |
54 | 54 | scope :active, where(:blocked => false) |
55 | 55 | |
56 | + before_validation :generate_password, :on1 => :create | |
57 | + | |
58 | + def generate_password | |
59 | + if self.password.blank? && self.password_confirmation.blank? | |
60 | + self.password = self.password_confirmation = Devise.friendly_token.first(8) | |
61 | + end | |
62 | + end | |
63 | + | |
56 | 64 | def self.filter filter_name |
57 | 65 | case filter_name |
58 | 66 | when "admins"; self.admins | ... | ... |