Sha256: f3412a87dea971e572092a516b991fe4ed18f174a00f314d085b08a36966eaef

Contents?: true

Size: 842 Bytes

Versions: 3

Compression:

Stored size: 842 Bytes

Contents

module Mks
  module Auth
    class User < ApplicationRecord
      # self.table_name = 'mks_users'

      belongs_to :application_module, class_name: 'Mks::Auth::ApplicationModule'
      has_and_belongs_to_many :roles, class_name: 'Mks::Auth::UserRole', join_table: :mks_auth_users_user_roles
      has_secure_password

      before_save { email.downcase! }

      VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
      validates :first_name, presence: true, length: {maximum: 30}
      validates :last_name, presence: true, length: {maximum: 30}
      validates :email, presence: true, format: { with: VALID_EMAIL_REGEX }, uniqueness: {case_sensitive: false}
      validates :password, length: { minimum: 6 }
      validates :active, presence: true

      def full_name
        "#{first_name} #{last_name}"
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mks_auth-1.4.0 app/models/mks/auth/user.rb
mks_auth-1.2.0 app/models/mks/auth/user.rb
mks_auth-1.0.0 app/models/mks/auth/user.rb