Sha256: 8bf6969cfe1072ab557fec62e1fdfff63f1650251d7e405c5b5e996487daf1ce
Contents?: true
Size: 1.28 KB
Versions: 13
Compression:
Stored size: 1.28 KB
Contents
module Spree class User < Spree::Base include UserAddress include UserMethods include UserPaymentSource devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :encryptable, encryptor: 'authlogic_sha512' devise :confirmable if Spree::Auth::Config[:confirmable] devise :validatable if Spree::Auth::Config[:validatable] acts_as_paranoid after_destroy :scramble_email_and_password before_validation :set_login users_table_name = User.table_name roles_table_name = Role.table_name scope :admin, -> { includes(:spree_roles).where("#{roles_table_name}.name" => "admin") } def self.admin_created? User.admin.exists? end def admin? has_spree_role?('admin') end protected def password_required? !persisted? || password.present? || password_confirmation.present? end private def set_login # for now force login to be same as email, eventually we will make this configurable, etc. self.login ||= email if email end def scramble_email_and_password self.email = SecureRandom.uuid + "@example.net" self.login = email self.password = SecureRandom.hex(8) self.password_confirmation = password save end end end
Version data entries
13 entries across 13 versions & 1 rubygems