unidom-visitor 0.6 → 0.7

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: 2deb20a10510bafbc43d8daed41bb0f6568f4cd8
4
- data.tar.gz: 5081d87ec23955780fd9ddc2b053cb457c6671c3
3
+ metadata.gz: 064eadc8ee5c8da6a38e3fe24c999c70ec2fa015
4
+ data.tar.gz: 408e16a5576d9ac99453ff6eb292c61edfcb4e8d
5
5
  SHA512:
6
- metadata.gz: 916792a07078800f18ba7dc49c5b01af83826918925749079d9090dc436e7b05d10d489225366f26b44981ec9880be49927a743f9e2431b9b917c8e9a05b6404
7
- data.tar.gz: 3b22150addef1f32cb4cfba4df5c0d079f4085151e49f5a8bb678d562b4aa1c08a9f22f9f108ef524a2825869e0ed00c93cdd9a95fda36e8513dca8cb9f8a537
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
+ ```
@@ -10,4 +10,4 @@
10
10
  // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11
11
  // about supported directives.
12
12
  //
13
- //= require_tree .
13
+ //= require_self
@@ -10,6 +10,5 @@
10
10
  * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
11
11
  * file per style scope.
12
12
  *
13
- *= require_tree .
14
13
  *= require_self
15
14
  */
@@ -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
- self.create! visitor: visitor, credential: credential, opened_at: opened_at
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, presence: true, length: { in: 6..200 }
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||::SecureRandom.hex(self.class.columns_hash['pepper_content'].limit/2)
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 'unidom/visitor/application', media: 'all' %>
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>
@@ -1,5 +1,5 @@
1
1
  module Unidom
2
2
  module Visitor
3
- VERSION = '0.6'.freeze
3
+ VERSION = '0.7'.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.6'
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-04-07 00:00:00.000000000 Z
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.7'
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.7'
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.5.1
81
+ rubygems_version: 2.6.4
82
82
  signing_key:
83
83
  specification_version: 4
84
84
  summary: Unidom Visitor Domain Model Engine 访问者领域模型引擎