Sha256: dbca3961ec98c817b762384d36cb881281dd99d7c6ffcd8a03170f61872e5d68

Contents?: true

Size: 1.05 KB

Versions: 4

Compression:

Stored size: 1.05 KB

Contents

# User 是系统用户。

class Unidom::Visitor::User < Unidom::Visitor::ApplicationRecord

  self.table_name = 'unidom_users'

  include Unidom::Common::Concerns::ModelExtension
  include Unidom::Visitor::Concerns::AsVisitor

  has_many :passwords, through: :authenticatings, source: :credential, source_type: 'Unidom::Visitor::Password'

  def self.sign_up(identity, password: nil, opened_at: Time.now)

    Rails.logger.debug "Signing up user with identity: #{identity.inspect}."
    return false if identified_by(identity).valid_at.alive.merge(Unidom::Visitor::Identificating.valid_at.alive).count>0

    user           = create! opened_at: opened_at
    identificating = Unidom::Visitor::Identificating.identificate! user, as: identity

    Rails.logger.debug "Authenticate user #{user.id} with password: #{password.inspect}."
    if password.present?
      credential     = Unidom::Visitor::Password.create! clear_text: password, opened_at: opened_at
      authenticating = Unidom::Visitor::Authenticating.authenticate! user, with: credential
    end

    user

  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
unidom-visitor-1.12.1 app/models/unidom/visitor/user.rb
unidom-visitor-1.12 app/models/unidom/visitor/user.rb
unidom-visitor-1.11.2 app/models/unidom/visitor/user.rb
unidom-visitor-1.11.1 app/models/unidom/visitor/user.rb