Commit 9132d309 authored by Jakub Troszok's avatar Jakub Troszok

Implementing automatic password creation.

parent 6d92aa6d
...@@ -53,6 +53,14 @@ class User < ActiveRecord::Base ...@@ -53,6 +53,14 @@ class User < ActiveRecord::Base
scope :blocked, where(:blocked => true) scope :blocked, where(:blocked => true)
scope :active, where(:blocked => false) scope :active, where(:blocked => false)
before_validation :generate_password, :on1 => :create
def generate_password
if self.password.blank? && self.password_confirmation.blank?
self.password = self.password_confirmation = Devise.friendly_token.first(8)
end
end
def self.filter filter_name def self.filter filter_name
case filter_name case filter_name
when "admins"; self.admins when "admins"; self.admins
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment