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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 913a331e2c09930f4292bdec1b2e36fce8467a39c3a7e1f21d4cb3da10b1beb2
|
4
|
+
data.tar.gz: 5c46e61be56782930376f8aaf78321b185d01333e2d1ea8c2f6bc3d8f4fe6376
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
59
|
-
# user.password == 'foo'
|
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?
|
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
|
105
|
+
# user.encrypted_password # => nil
|
87
106
|
# user.password = 'foo'
|
88
|
-
# user.encrypted_password
|
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 =
|
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
|