Sha256: 0298e69eafb7027b0e2f3e51341b1e04c2681a2c2f71c3c04ba1a8582777c836

Contents?: true

Size: 725 Bytes

Versions: 3

Compression:

Stored size: 725 Bytes

Contents

require 'bcrypt' if RUBY_PLATFORM != 'opal'

module Volt
  class User < Model
    # returns true if the user configured using the username
    def self.login_field
      if Volt.config.public.try(:auth).try(:use_username)
        :username
      else
        :email
      end
    end

    validate login_field, unique: true, length: 8
    validate :email, email: true

    if RUBY_PLATFORM == 'opal'
      # Don't validate on the server
      validate :password, length: 8
    end

    def password=(val)
      if Volt.server?
        # on the server, we bcrypt the password and store the result
        self._hashed_password = BCrypt::Password.create(val)
      else
        self._password = val
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
volt-0.8.27.beta2 app/volt/models/user.rb
volt-0.8.27.beta1 app/volt/models/user.rb
volt-0.8.26.beta1 app/volt/models/user.rb