unidom-visitor 0.4 → 0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 491067fb998268e5617f760e85cf50d5952b8a53
4
- data.tar.gz: c4f5bb60ad59a119f846aa30b23da1536b5a0b9b
3
+ metadata.gz: 714c4e6a3e454a732640343b4202d6c175c13d77
4
+ data.tar.gz: 7a8418e4a465732080e0776e650911142cd0e471
5
5
  SHA512:
6
- metadata.gz: b84f6c06b982f91fcdbbfeedc6f3e930385bbccc214426f908ce98667b7645140591770170a7f1e56c36760df3372ba0e1c01e0092bc964c60484aafe74b1b24
7
- data.tar.gz: bcadf0497db1c7f90214f4218b272f80f3bb0497be5d7b42c29f9b98f60650f7a6d8e8110406f6d66640efc43e25523beefc9d0a0d0b25d0dbd123daf6ddd76f
6
+ metadata.gz: 26cba1129754ecdc5db6e62f6a721b22683810fee6a3dfe1db9b1a6afff387ae03cdd96e497814d516816724e5aa8f72aab284ef5637effe3817b77a618d2a24
7
+ data.tar.gz: 5776aa07d31a1a35a9e51041be7700099c8eafbb9300dd6495ee7adaa76008e94c72f3f494b2a19a889e8ba0fdacb4157812aad86c6917bf08874959f54bb592
data/README.md CHANGED
@@ -6,6 +6,10 @@
6
6
  Unidom (UNIfied Domain Object Model) is a series of domain model engines. The Visitor domain model engine includes User, Guest, Administrator, and Password models.
7
7
  Unidom (统一领域对象模型)是一系列的领域模型引擎。访问者领域模型引擎包括用户、游客、管理员和密码的模型。
8
8
 
9
+ ## Recent Update
10
+ Check out the [Road Map](ROADMAP.md) to find out what's the next.
11
+ Check out the [Change Log](CHANGELOG.md) to find out what's new.
12
+
9
13
  ## Usage in Gemfile
10
14
  ```ruby
11
15
  gem 'unidom-visitor'
@@ -15,13 +19,18 @@ gem 'unidom-visitor'
15
19
  ```shell
16
20
  rake db:migrate
17
21
  ```
22
+ The migration versions start with 200002.
18
23
 
19
24
  ## Call the Model
20
25
  ```ruby
21
- phone = PhoneNumberIdentity.create phone_number: '13912345678'
22
- Unidom::Visitor::User.sign_up phone, 'password', opened_at: Time.now
26
+ phone_1 = PhoneNumberIdentity.create phone_number: '13912345678'
27
+ Unidom::Visitor::User.sign_up phone_1, password: 'password', opened_at: Time.now
23
28
  # Sign up a user with given phone number and password
24
29
 
30
+ phone_2 = PhoneNumberIdentity.create phone_number: '13912345679'
31
+ Unidom::Visitor::User.sign_up phone_2, opened_at: Time.now
32
+ # Sign up a user with the given phone number & password not set
33
+
25
34
  Unidom::Visitor::Guest.valid_at.alive.first
26
35
  # Get the first guest
27
36
 
@@ -11,19 +11,23 @@ class Unidom::Visitor::User < ActiveRecord::Base
11
11
 
12
12
  has_many :recognizations, class_name: 'Unidom::Visitor::Recognization', as: :visitor
13
13
 
14
- scope :identified_by, ->(identity) { joins(:identificatings).merge(::Unidom::Visitor::Identificating.identity_is identity) }
14
+ scope :identified_by, ->(identity) { joins(:identificatings).merge(Unidom::Visitor::Identificating.identity_is identity) }
15
15
 
16
16
  include Unidom::Common::Concerns::ModelExtension
17
17
 
18
- def self.sign_up(identity, password, opened_at: Time.now)
18
+ def self.sign_up(identity, password: nil, opened_at: Time.now)
19
19
 
20
- return false if identified_by(identity).valid_at.alive.merge(::Unidom::Visitor::Identificating.valid_at.alive).count>0
20
+ Rails.logger.debug "Signing up user with identity: #{identity.inspect}."
21
+ return false if identified_by(identity).valid_at.alive.merge(Unidom::Visitor::Identificating.valid_at.alive).count>0
21
22
 
22
- user = self.create! opened_at: opened_at
23
- credential = ::Unidom::Visitor::Password.create! clear_text: password, opened_at: opened_at
23
+ user = self.create! opened_at: opened_at
24
+ identificating = Unidom::Visitor::Identificating.identificate user, identity
24
25
 
25
- identificating = ::Unidom::Visitor::Identificating.identificate user, identity
26
- authenticating = ::Unidom::Visitor::Authenticating.authenticate user, credential
26
+ Rails.logger.debug "Authenticate user #{user.id} with password: #{password.inspect}."
27
+ if password.present?
28
+ credential = Unidom::Visitor::Password.create! clear_text: password, opened_at: opened_at
29
+ authenticating = Unidom::Visitor::Authenticating.authenticate user, credential
30
+ end
27
31
 
28
32
  user
29
33
 
@@ -1,5 +1,5 @@
1
1
  module Unidom
2
2
  module Visitor
3
- VERSION = '0.4'.freeze
3
+ VERSION = '0.5'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unidom-visitor
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.4'
4
+ version: '0.5'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Topbit Du
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-26 00:00:00.000000000 Z
11
+ date: 2016-04-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: unidom-common
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.5'
19
+ version: '0.7'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0.5'
26
+ version: '0.7'
27
27
  description: Unidom (UNIfied Domain Object Model) is a series of domain model engines.
28
28
  The Visitor domain model engine includes User, Guest, Administrator, and Password
29
29
  models. Unidom (统一领域对象模型)是一系列的领域模型引擎。访问者领域模型引擎包括用户、游客、管理员和密码的模型。