Project

General

Profile

« Previous | Next » 

Revision fea5a7a4

Added by Brad Buckingham over 10 years ago

fixes #3669 - migration: minimize amount of User model exposed to migration

View differences:

db/migrate/20100628123400_add_internal_auth.rb
require 'facter'
class AddInternalAuth < ActiveRecord::Migration
class User < ActiveRecord::Base
attr_accessor :password
before_validation :prepare_password
def prepare_password
unless password.blank?
self.password_salt = Digest::SHA1.hexdigest([Time.now, rand].join)
self.password_hash = encrypt_password(password)
end
end
def encrypt_password(pass)
Digest::SHA1.hexdigest([pass, password_salt].join)
end
end
def self.up
add_column :users, :password_hash, :string, :limit => 128
......
src.update_attribute :name, "Internal"
user.auth_source_id = src.id
user.password="changeme"
if user.save_without_auditing
if user.save
say "****************************************************************************************"
say "The newly created internal account named admin has been allocated a password of 'changeme'"
say "Set this to something else in the settings/users page"

Also available in: Unified diff