Class: Unidom::Visitor::User

Inherits:
ApplicationRecord show all
Includes:
Common::Concerns::ModelExtension, Concerns::AsVisitor
Defined in:
app/models/unidom/visitor/user.rb

Overview

User 是系统用户。

Class Method Summary collapse

Class Method Details

.sign_up(identity, password: nil, opened_at: Time.now) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/models/unidom/visitor/user.rb', line 16

def self.(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