unidom-visitor 0.4 → 0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +11 -2
- data/app/models/unidom/visitor/user.rb +11 -7
- data/lib/unidom/visitor/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 714c4e6a3e454a732640343b4202d6c175c13d77
|
4
|
+
data.tar.gz: 7a8418e4a465732080e0776e650911142cd0e471
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
22
|
-
Unidom::Visitor::User.sign_up
|
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(
|
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
|
-
|
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
|
23
|
-
|
23
|
+
user = self.create! opened_at: opened_at
|
24
|
+
identificating = Unidom::Visitor::Identificating.identificate user, identity
|
24
25
|
|
25
|
-
|
26
|
-
|
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
|
|
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
|
+
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-
|
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.
|
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.
|
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 (统一领域对象模型)是一系列的领域模型引擎。访问者领域模型引擎包括用户、游客、管理员和密码的模型。
|