unidom-visitor 1.12.3 → 1.12.4
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 +39 -21
- data/app/controllers/unidom/visitor/application_controller.rb +3 -0
- data/app/jobs/unidom/visitor/application_job.rb +3 -0
- data/app/mailers/unidom/visitor/application_mailer.rb +3 -0
- data/app/models/unidom/visitor/application_record.rb +3 -0
- data/app/models/unidom/visitor/authenticating.rb +4 -1
- data/app/models/unidom/visitor/guest.rb +1 -1
- data/app/models/unidom/visitor/identificating.rb +4 -1
- data/app/models/unidom/visitor/password.rb +4 -1
- data/app/models/unidom/visitor/recognization.rb +4 -1
- data/app/models/unidom/visitor/user.rb +4 -1
- 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: 11c45fb8f48e47ced170d411d5340609f6e8e50a
|
|
4
|
+
data.tar.gz: a40ac60d84c5995be8bc47d33a3af648f2753dc6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f39fef87984dc8d517eb859e9540a0bbd983fe048d463e26f134affb9aacacdfc8d0915c0084293435ace4d2ae8b86def6cea2616b0740511824cca31b27e3e2
|
|
7
|
+
data.tar.gz: b625dce0ac7a1b79651974a57b14f81044984cb0a5521b43d53d556133e737c8bbf0b6eafb5f2db3009f572a231e3fc559d02c727e5095e6be544a5d80052bd6
|
data/README.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# Unidom Visitor 访问者领域模型引擎
|
|
2
2
|
|
|
3
|
+
[](http://www.rubydoc.info/gems/unidom-visitor/frames)
|
|
3
4
|
[](http://opensource.org/licenses/MIT)
|
|
5
|
+
|
|
4
6
|
[](https://badge.fury.io/rb/unidom-visitor)
|
|
5
7
|
[](https://gemnasium.com/github.com/topbitdu/unidom-visitor)
|
|
6
8
|
|
|
@@ -89,39 +91,39 @@ include Unidom::Visitor::Concerns::AsParty
|
|
|
89
91
|
|
|
90
92
|
### As Visitor concern
|
|
91
93
|
|
|
92
|
-
The As Visitor concern do the following tasks for the includer automatically:
|
|
93
|
-
1. Define the has_many :identificatings macro as: ``has_many :identificatings, class_name: 'Unidom::Visitor::Identificating', as: :visitor``
|
|
94
|
-
2. Define the has_many :authenticatings macro as: ``has_many :authenticatings, class_name: 'Unidom::Visitor::Authenticating', as: :visitor``
|
|
95
|
-
3. Define the has_many :recognizations macro as: ``has_many :recognizations, class_name: 'Unidom::Visitor::Recognization', as: :visitor``
|
|
96
|
-
4. Define the .identified_by scope as: ``scope :identified_by, ->(identity) { joins(:identificatings).merge(Unidom::Visitor::Identificating.identity_is identity) }``
|
|
97
|
-
5. Define the .sign_up method as: ``sign_up(identity, password: nil, opened_at: Time.now)``
|
|
98
|
-
6. Define the #is_identificated! method as: ``is_identificated!(as: nil, at: Time.now)``
|
|
99
|
-
7. Define the #is_identificated? method as: ``is_identificated?(as: nil, at: Time.now)``
|
|
100
|
-
8. Define the #is_authenticated! method as: ``is_authenticated!(through: nil, at: Time.now, flag_code: 'RQRD')``
|
|
101
|
-
9. Define the #is_authenticated? method as: ``is_authenticated?(through: nil, at: Time.now, flag_code: 'RQRD')``
|
|
102
|
-
10. Define the #cognize! method as: ``cognize!(it, at: Time.now, primary: true)``
|
|
103
|
-
11. Define the #cognize? method as: ``cognize?(it, at: Time.now, primary: true)``
|
|
94
|
+
The As Visitor concern do the following tasks for the includer automatically:
|
|
95
|
+
1. Define the has_many :identificatings macro as: ``has_many :identificatings, class_name: 'Unidom::Visitor::Identificating', as: :visitor``
|
|
96
|
+
2. Define the has_many :authenticatings macro as: ``has_many :authenticatings, class_name: 'Unidom::Visitor::Authenticating', as: :visitor``
|
|
97
|
+
3. Define the has_many :recognizations macro as: ``has_many :recognizations, class_name: 'Unidom::Visitor::Recognization', as: :visitor``
|
|
98
|
+
4. Define the .identified_by scope as: ``scope :identified_by, ->(identity) { joins(:identificatings).merge(Unidom::Visitor::Identificating.identity_is identity) }``
|
|
99
|
+
5. Define the .sign_up method as: ``sign_up(identity, password: nil, opened_at: Time.now)``
|
|
100
|
+
6. Define the #is_identificated! method as: ``is_identificated!(as: nil, at: Time.now)``
|
|
101
|
+
7. Define the #is_identificated? method as: ``is_identificated?(as: nil, at: Time.now)``
|
|
102
|
+
8. Define the #is_authenticated! method as: ``is_authenticated!(through: nil, at: Time.now, flag_code: 'RQRD')``
|
|
103
|
+
9. Define the #is_authenticated? method as: ``is_authenticated?(through: nil, at: Time.now, flag_code: 'RQRD')``
|
|
104
|
+
10. Define the #cognize! method as: ``cognize!(it, at: Time.now, primary: true)``
|
|
105
|
+
11. Define the #cognize? method as: ``cognize?(it, at: Time.now, primary: true)``
|
|
104
106
|
12. Define the .sign_up! method as: ``sign_up!(it, as: nil, through: nil, at: Time.now, flag_code: 'RQRD', primary: true)``
|
|
105
107
|
|
|
106
108
|
### As Identity concern
|
|
107
109
|
|
|
108
|
-
The As Identity concern do the following tasks for the includer automatically:
|
|
109
|
-
1. Define the has_many :identificatings macro as: ``has_many :identificatings, class_name: 'Unidom::Visitor::Identificating', as: :identity``
|
|
110
|
-
2. Define the #identificate! method as: ``identificate!(it, at: Time.now)``
|
|
110
|
+
The As Identity concern do the following tasks for the includer automatically:
|
|
111
|
+
1. Define the has_many :identificatings macro as: ``has_many :identificatings, class_name: 'Unidom::Visitor::Identificating', as: :identity``
|
|
112
|
+
2. Define the #identificate! method as: ``identificate!(it, at: Time.now)``
|
|
111
113
|
3. Define the #identificate? method as: ``identificate?(it, at: Time.now)``
|
|
112
114
|
|
|
113
115
|
### As Credential concern
|
|
114
116
|
|
|
115
|
-
The As Credential concern do the following tasks for the includer automatically:
|
|
116
|
-
1. Define the has_one :authenticatings macro as: ``has_one :authenticating, class_name: 'Unidom::Visitor::Authenticating', as: :credential``
|
|
117
|
-
2. Define the #authenticate! method as: ``authenticate!(it, at: Time.now, flag_code: 'RQRD')``
|
|
117
|
+
The As Credential concern do the following tasks for the includer automatically:
|
|
118
|
+
1. Define the has_one :authenticatings macro as: ``has_one :authenticating, class_name: 'Unidom::Visitor::Authenticating', as: :credential``
|
|
119
|
+
2. Define the #authenticate! method as: ``authenticate!(it, at: Time.now, flag_code: 'RQRD')``
|
|
118
120
|
3. Define the #authenticate? method as: ``authenticate?(it, at: Time.now, flag_code: 'RQRD')``
|
|
119
121
|
|
|
120
122
|
### As Party concern
|
|
121
123
|
|
|
122
|
-
The As Party concern do the following tasks for the includer automatically:
|
|
123
|
-
1. Define the has_many :recognizations macro as: ``has_many :recognizations, class_name: 'Unidom::Visitor::Recognization', as: :party``
|
|
124
|
-
2. Define the #is_cognized! method as: ``is_cognized!(via: nil, at: Time.now, primary: true)``
|
|
124
|
+
The As Party concern do the following tasks for the includer automatically:
|
|
125
|
+
1. Define the has_many :recognizations macro as: ``has_many :recognizations, class_name: 'Unidom::Visitor::Recognization', as: :party``
|
|
126
|
+
2. Define the #is_cognized! method as: ``is_cognized!(via: nil, at: Time.now, primary: true)``
|
|
125
127
|
3. Define the #is_cognized? method as: ``is_cognized!(via: nil, at: Time.now, primary: true)``
|
|
126
128
|
|
|
127
129
|
|
|
@@ -137,3 +139,19 @@ Unidom::Visitor::Flag::SUFFICIENT
|
|
|
137
139
|
Unidom::Visitor::Flag::REQUISITE
|
|
138
140
|
Unidom::Visitor::Flag::OPTIONAL
|
|
139
141
|
```
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
## Disable the Model & Migration
|
|
146
|
+
|
|
147
|
+
If you only need the app components other than models, the migrations should be neglected, and the models should not be loaded.
|
|
148
|
+
```ruby
|
|
149
|
+
# config/initializers/unidom.rb
|
|
150
|
+
Unidom::Common.configure do |options|
|
|
151
|
+
|
|
152
|
+
options[:neglected_namespaces] = %w{
|
|
153
|
+
Unidom::Visitor
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
end
|
|
157
|
+
```
|
|
@@ -19,10 +19,13 @@ class Unidom::Visitor::Authenticating < Unidom::Visitor::ApplicationRecord
|
|
|
19
19
|
scope :visitor_type_is, ->(visitor_type) { where visitor_type: visitor_type }
|
|
20
20
|
scope :credential_type_is, ->(credential_type) { where credential_type: credential_type }
|
|
21
21
|
|
|
22
|
+
##
|
|
23
|
+
# 将访问者 visitor 和信任状 credential 关联起来。关联时间是 opened_at ,缺省是当前时间。如:
|
|
24
|
+
# Unidom::Visitor::Authenticating.authenticate! user, with: password
|
|
22
25
|
def self.authenticate!(visitor, with: nil, opened_at: Time.now)
|
|
23
26
|
credential_is(with).visitor_is(visitor).valid_at.alive.first_or_create! opened_at: opened_at
|
|
24
27
|
end
|
|
25
28
|
|
|
26
29
|
code :flag, Unidom::Visitor::Flag
|
|
27
30
|
|
|
28
|
-
end
|
|
31
|
+
end unless Unidom::Common::Neglection.namespace_neglected? 'Unidom::Visitor::Authenticating'
|
|
@@ -11,4 +11,4 @@ class Unidom::Visitor::Guest < Unidom::Visitor::ApplicationRecord
|
|
|
11
11
|
|
|
12
12
|
scope :platform_specific_identification_is, ->(platform_specific_identification) { where platform_specific_identification: platform_specific_identification }
|
|
13
13
|
|
|
14
|
-
end
|
|
14
|
+
end unless Unidom::Common::Neglection.namespace_neglected? 'Unidom::Visitor::Guest'
|
|
@@ -17,8 +17,11 @@ class Unidom::Visitor::Identificating < Unidom::Visitor::ApplicationRecord
|
|
|
17
17
|
visitor_is(visitor).first.try :identity
|
|
18
18
|
end
|
|
19
19
|
|
|
20
|
+
##
|
|
21
|
+
# 将访问者 visitor 和参与者 party 进行身份关联。关联时间是 at ,缺省为当前时间。如:
|
|
22
|
+
# Unidom::Visitor::Identificating.identificate! user, as: email
|
|
20
23
|
def self.identificate!(visitor, as: nil, at: Time.now)
|
|
21
24
|
self.visitor_is(visitor).identity_is(as).valid_at.alive.first_or_create! opened_at: at
|
|
22
25
|
end
|
|
23
26
|
|
|
24
|
-
end
|
|
27
|
+
end unless Unidom::Common::Neglection.namespace_neglected? 'Unidom::Visitor::Identificating'
|
|
@@ -35,6 +35,9 @@ class Unidom::Visitor::Password < Unidom::Visitor::ApplicationRecord
|
|
|
35
35
|
Digest::SHA512.hexdigest "#{::Rails.application.secrets[:secret_key_base]}#{clear_text}#{self.pepper_content}"
|
|
36
36
|
end
|
|
37
37
|
|
|
38
|
+
##
|
|
39
|
+
# 将当前密码更换为指定的新密码。如:
|
|
40
|
+
# password.change_to 'newpassword'
|
|
38
41
|
def change_to(new_password)
|
|
39
42
|
visitor = authenticating.visitor
|
|
40
43
|
soft_destroy
|
|
@@ -50,4 +53,4 @@ class Unidom::Visitor::Password < Unidom::Visitor::ApplicationRecord
|
|
|
50
53
|
|
|
51
54
|
private :hash
|
|
52
55
|
|
|
53
|
-
end
|
|
56
|
+
end unless Unidom::Common::Neglection.namespace_neglected? 'Unidom::Visitor::Password'
|
|
@@ -13,6 +13,9 @@ class Unidom::Visitor::Recognization < Unidom::Visitor::ApplicationRecord
|
|
|
13
13
|
scope :visitor_is, ->(visitor) { where visitor: visitor }
|
|
14
14
|
scope :party_is, ->(party) { where party: party }
|
|
15
15
|
|
|
16
|
+
##
|
|
17
|
+
# 将访问者 visitor 和参与者 party 关联起来。关联时间为 at ,缺省为当前时间。主关联标志为 primary ,缺省为 false 。如:
|
|
18
|
+
# Unidom::Visitor::Recognization.cognize! user, as: selected_person
|
|
16
19
|
def self.cognize!(visitor, as: nil, at: Time.now, primary: false)
|
|
17
20
|
query = visitor_is(visitor).party_is(as).valid_at.alive
|
|
18
21
|
recognization = query.first
|
|
@@ -25,4 +28,4 @@ class Unidom::Visitor::Recognization < Unidom::Visitor::ApplicationRecord
|
|
|
25
28
|
end
|
|
26
29
|
end
|
|
27
30
|
|
|
28
|
-
end
|
|
31
|
+
end unless Unidom::Common::Neglection.namespace_neglected? 'Unidom::Visitor::Recognization'
|
|
@@ -10,6 +10,9 @@ class Unidom::Visitor::User < Unidom::Visitor::ApplicationRecord
|
|
|
10
10
|
|
|
11
11
|
has_many :passwords, through: :authenticatings, source: :credential, source_type: 'Unidom::Visitor::Password'
|
|
12
12
|
|
|
13
|
+
##
|
|
14
|
+
# 注册用户。用户的登录账号是 identity ,密码是 password ,注册时间是 opened_at ,缺省为当前时间。如:
|
|
15
|
+
# Unidom::Visitor::User.sign_up email, password: 'yourpassword'
|
|
13
16
|
def self.sign_up(identity, password: nil, opened_at: Time.now)
|
|
14
17
|
|
|
15
18
|
Rails.logger.debug "Signing up user with identity: #{identity.inspect}."
|
|
@@ -28,4 +31,4 @@ class Unidom::Visitor::User < Unidom::Visitor::ApplicationRecord
|
|
|
28
31
|
|
|
29
32
|
end
|
|
30
33
|
|
|
31
|
-
end
|
|
34
|
+
end unless Unidom::Common::Neglection.namespace_neglected? 'Unidom::Visitor::User'
|
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: 1.12.
|
|
4
|
+
version: 1.12.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Topbit Du
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2017-01-
|
|
11
|
+
date: 2017-01-28 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: '1.
|
|
19
|
+
version: '1.9'
|
|
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: '1.
|
|
26
|
+
version: '1.9'
|
|
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 (统一领域对象模型)是一系列的领域模型引擎。访问者领域模型引擎包括用户、游客、管理员和密码的模型。
|