Sha256: c2d62c4bb5ccc7b148157b4fcacf80757811d1c604d2a37ec4e43d8270099b4d
Contents?: true
Size: 1.26 KB
Versions: 6
Compression:
Stored size: 1.26 KB
Contents
module Tienda class User < ActiveRecord::Base self.table_name = 'tienda_users' has_secure_password # Validations validates :first_name, presence: true validates :last_name, presence: true validates :email_address, presence: true # The user's first name & last name concatenated # # @return [String] def full_name "#{first_name} #{last_name}" end # The user's first name & initial of last name concatenated # # @return [String] def short_name "#{first_name} #{last_name[0,1]}" end # Reset the user's password to something random and e-mail it to them def reset_password! self.password = SecureRandom.hex(8) self.password_confirmation = self.password self.save! Tienda::UserMailer.new_password(self).deliver end # Attempt to authenticate a user based on email & password. Returns the # user if successful otherwise returns false. # # @param email_address [String] # @param paassword [String] # @return [Tienda::User] def self.authenticate(email_address, password) user = self.where(email_address: email_address).first return false if user.nil? return false unless user.authenticate(password) user end end end
Version data entries
6 entries across 6 versions & 1 rubygems