sequel_simple_oauth2 0.1.0 → 0.2.0

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
  SHA256:
3
- metadata.gz: 53006a40c16c0f2b5bf90b71cb711cf846581e36c042e3d61ad62d5612c82ff2
4
- data.tar.gz: c3c0b7aa1f2df17d89d9180beb9ad85325de46499d61889127355bff86246679
3
+ metadata.gz: 913a331e2c09930f4292bdec1b2e36fce8467a39c3a7e1f21d4cb3da10b1beb2
4
+ data.tar.gz: 5c46e61be56782930376f8aaf78321b185d01333e2d1ea8c2f6bc3d8f4fe6376
5
5
  SHA512:
6
- metadata.gz: 3144794a8c449f6be7bf2270264d3b10cf5ec3a0e75823a0886fdf6b1f12c763108ee81f1ece101a9b9528182a4ef249ff294357f4534a7a1a70e6d02b1ade85
7
- data.tar.gz: 2e165f47922a377258e8aebe98fff39e7f5fe42d7d50d36e9c099c747f8f3182b2b57271094851ef8fae907f7123468c0b12b6209a2516d32b2f14a37fe41eaf
6
+ metadata.gz: 15ab1fb48bbf64c7481b378e08b2f06ffe6a9d4ca36025e00b11a05c3e7084cf48d38cbec8a83a68ffcfa1bd9a3932ecf044b2fcd070774ef4eafa7974871022
7
+ data.tar.gz: b158b736e015cddf1249418c428833127faff8e2ba11bce3ed9cf16eeea044b12379063492bc4b4eb27f2e0ab5fe7273206e44ba62810a07b771f0dc077f8100
@@ -31,6 +31,26 @@ module Sequel
31
31
  end
32
32
  end
33
33
 
34
+ # Searches for ResourceOwner record with the specific params.
35
+ #
36
+ # @param _client [Object] Client instance.
37
+ # @param username [String, #to_s] username value (any object that responds to `#to_s`).
38
+ # @param password [String] password value.
39
+ #
40
+ # @return [Object, nil] ResourceOwner object or nil if there is no record with such params.
41
+ #
42
+ # @example
43
+ # User.create(username: 'foo', password: 'foo')
44
+ # user = User.oauth_authenticate(nil, 'foo', 'password')
45
+ # user.username # => 'foo'
46
+ # another_user = User.oauth_authenticate(nil, 'notfoo', 'password')
47
+ # another_user # => nil
48
+ #
49
+ def self.oauth_authenticate(_client, username, password)
50
+ resource_owner = first(username: username.to_s)
51
+ resource_owner && resource_owner.authenticate(password)
52
+ end
53
+
34
54
  # Returns resource if the password is correct, otherwise +false+.
35
55
  #
36
56
  # @param pass [String] Password value.
@@ -45,7 +65,6 @@ module Sequel
45
65
  #
46
66
  def authenticate(pass)
47
67
  password.is_password?(pass) && self
48
- # BCrypt::Password.new(encrypted_password).is_password?(pass) && self
49
68
  end
50
69
 
51
70
  # Returns encrypted password if encrypted_password is not empty.
@@ -55,8 +74,8 @@ module Sequel
55
74
  # @example
56
75
  # user = User.new
57
76
  # user.password = 'foo'
58
- # user.password #=> "$2a$10$4LEA7r4YmNHtvlAvHhsYAeZmk/xeUVtMTYqwIvYY76EW5GUqDiP4."
59
- # user.password == 'foo' #=> true
77
+ # user.password # => "$2a$10$4LEA7r4YmNHtvlAvHhsYAeZmk/xeUVtMTYqwIvYY76EW5GUqDiP4."
78
+ # user.password == 'foo' # => true
60
79
  #
61
80
  def password
62
81
  @password ||= BCrypt::Password.new(encrypted_password) if encrypted_password
@@ -68,7 +87,7 @@ module Sequel
68
87
  #
69
88
  # @example
70
89
  # user = User.new
71
- # user.min_cost? #=> false
90
+ # user.min_cost? # => false
72
91
  #
73
92
  def min_cost?
74
93
  false
@@ -83,9 +102,9 @@ module Sequel
83
102
  # @example
84
103
  # user = User.new
85
104
  # user.password = nil
86
- # user.encrypted_password #=> nil
105
+ # user.encrypted_password # => nil
87
106
  # user.password = 'foo'
88
- # user.encrypted_password #=> "$2a$10$4LEA7r4YmNHtvlAvHhsYAeZmk/xeUVtMTYqwIvYY76EW5GUqDiP4."
107
+ # user.encrypted_password # => "$2a$10$4LEA7r4YmNHtvlAvHhsYAeZmk/xeUVtMTYqwIvYY76EW5GUqDiP4."
89
108
  #
90
109
  def password=(pass)
91
110
  if pass.present? && pass.length >= MAX_PASSWORD_LENGTH_ALLOWED
@@ -16,7 +16,7 @@ module Sequel
16
16
  # Level changes for implementation level detail changes, such as small bug fixes
17
17
  PATCH = 0
18
18
  # Level changes for any backwards compatible API changes, such as new functionality/features
19
- MINOR = 1
19
+ MINOR = 2
20
20
  # Level changes for backwards incompatible API changes,
21
21
  # such as changes that will break existing users code if they update
22
22
  MAJOR = 0
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sequel_simple_oauth2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Volodimir Partytskyi