unidom-visitor 0.6 → 0.7
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 +7 -0
- data/app/assets/javascripts/unidom/visitor/application.js +1 -1
- data/app/assets/stylesheets/unidom/visitor/application.css +0 -1
- data/app/models/unidom/visitor/authenticating.rb +11 -3
- data/app/models/unidom/visitor/password.rb +5 -2
- data/app/views/layouts/unidom/visitor/application.html.erb +3 -2
- data/lib/unidom/visitor/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 064eadc8ee5c8da6a38e3fe24c999c70ec2fa015
|
4
|
+
data.tar.gz: 408e16a5576d9ac99453ff6eb292c61edfcb4e8d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b2cc1d6a7ba9786a4547b9fce770dfede381b464741a736e838aa532a5879314c3588e585c7098ad0d2075622118b25fe86cfa2374fea45e75aa9109525908c3
|
7
|
+
data.tar.gz: 17d03d5fe0737084b1ba556ca4656df6033e188e90bad68d80d6c2bcd071ef83ad0efb448147b6e53a758e141ab781afa127e3edab5c447aadc814546729e5a6
|
data/README.md
CHANGED
@@ -38,3 +38,10 @@ if Unidom::Visitor::User.valid_at.alive.first.passwords.valid_at.alive.first.mer
|
|
38
38
|
# Sign in
|
39
39
|
end
|
40
40
|
```
|
41
|
+
|
42
|
+
### Authenticating model
|
43
|
+
```ruby
|
44
|
+
user = Unidom::Visitor::User.create! opened_at: Time.now
|
45
|
+
password = Unidom::Visitor::Password.create! clear_text: 'password', opened_at: Time.now
|
46
|
+
Unidom::Visitor::Authenticating.authenticate! user, password
|
47
|
+
```
|
@@ -6,6 +6,8 @@ class Unidom::Visitor::Authenticating < ActiveRecord::Base
|
|
6
6
|
|
7
7
|
self.table_name = 'unidom_authenticatings'
|
8
8
|
|
9
|
+
include Unidom::Common::Concerns::ModelExtension
|
10
|
+
|
9
11
|
belongs_to :visitor, polymorphic: true
|
10
12
|
belongs_to :credential, polymorphic: true
|
11
13
|
|
@@ -15,10 +17,16 @@ class Unidom::Visitor::Authenticating < ActiveRecord::Base
|
|
15
17
|
scope :visitor_type_is, ->(visitor_type) { where visitor_type: visitor_type }
|
16
18
|
scope :credential_type_is, ->(credential_type) { where credential_type: credential_type }
|
17
19
|
|
18
|
-
include Unidom::Common::Concerns::ModelExtension
|
19
|
-
|
20
20
|
def self.authenticate(visitor, credential, opened_at: Time.now)
|
21
|
-
|
21
|
+
authenticate! visitor, credential, opened_at
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.authenticate!(visitor, credential, opened_at: Time.now)
|
25
|
+
credential_is(credential).visitor_is(visitor).valid_at.alive.first_or_create! opened_at: opened_at
|
26
|
+
end
|
27
|
+
|
28
|
+
class << self
|
29
|
+
deprecate authenticate: :authenticate!, deprecator: ActiveSupport::Deprecation.new('1.0', 'unidom-visitor')
|
22
30
|
end
|
23
31
|
|
24
32
|
end
|
@@ -6,12 +6,15 @@ class Unidom::Visitor::Password < ActiveRecord::Base
|
|
6
6
|
|
7
7
|
include Unidom::Common::Concerns::ModelExtension
|
8
8
|
|
9
|
-
validates :clear_text,
|
9
|
+
validates :clear_text, presence: true, length: { in: 6..200 }
|
10
|
+
validates :pepper_content, presence: true, length: { is: columns_hash['pepper_content'].limit }
|
10
11
|
|
11
12
|
has_one :authenticating, class_name: 'Unidom::Visitor::Authenticating', as: :credential
|
12
13
|
|
14
|
+
before_validation :generate_pepper_content
|
15
|
+
|
13
16
|
def generate_pepper_content
|
14
|
-
self.pepper_content = self.pepper_content
|
17
|
+
self.pepper_content = self.pepper_content||SecureRandom.hex(self.class.columns_hash['pepper_content'].limit/2)
|
15
18
|
end
|
16
19
|
|
17
20
|
def clear_text
|
@@ -2,13 +2,14 @@
|
|
2
2
|
<html>
|
3
3
|
<head>
|
4
4
|
<title>Unidom Visitor</title>
|
5
|
-
<%= stylesheet_link_tag
|
6
|
-
<%= javascript_include_tag 'unidom/visitor/application' %>
|
5
|
+
<%= stylesheet_link_tag 'unidom/visitor/application', media: 'all' %>
|
7
6
|
<%= csrf_meta_tags %>
|
8
7
|
</head>
|
9
8
|
<body>
|
10
9
|
|
11
10
|
<%= yield %>
|
12
11
|
|
12
|
+
<%= javascript_include_tag 'unidom/visitor/application' %>
|
13
|
+
|
13
14
|
</body>
|
14
15
|
</html>
|
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.7'
|
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-07-21 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.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: '0.
|
26
|
+
version: '0.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 (统一领域对象模型)是一系列的领域模型引擎。访问者领域模型引擎包括用户、游客、管理员和密码的模型。
|
@@ -78,7 +78,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
78
78
|
version: '0'
|
79
79
|
requirements: []
|
80
80
|
rubyforge_project:
|
81
|
-
rubygems_version: 2.4
|
81
|
+
rubygems_version: 2.6.4
|
82
82
|
signing_key:
|
83
83
|
specification_version: 4
|
84
84
|
summary: Unidom Visitor Domain Model Engine 访问者领域模型引擎
|