uc3-dmp-rds 0.0.17 → 0.0.18
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/lib/uc3-dmp-rds/authenticator.rb +1 -20
- data/lib/uc3-dmp-rds/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ef65457155892c90bf5172d0a6bdbcf81f65a9c207f460f37100995f6895f1a6
|
4
|
+
data.tar.gz: 31d3dd6a9c5a831f3aff7c9407dadc0cc1957b19058003fa85f3638dd55b59ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0196dd990fa57ea307f7a29888f2d96863b764ab20ec0df43d61a7d6180d855b5f3b07c511f3b255e5f70cd10e9a108edc46aa4f3bb034d520112ceecf3cb969'
|
7
|
+
data.tar.gz: 630ea47371bb9a4e353423e3eca70df20302e92716e2ff0020d98b7a80d8a8957392754234176bc92e587929216ecb0a9d988bf5c1e8ada16cd175a88317a03f
|
@@ -18,19 +18,11 @@ module Uc3DmpRds
|
|
18
18
|
# Look up the user based on the API token. Will fail if Uc3DmpRds::Adapter does not
|
19
19
|
# have an established connection!
|
20
20
|
def authenticate(token:)
|
21
|
-
|
22
|
-
puts "Authenticator called"
|
23
|
-
|
24
|
-
|
25
21
|
raise AuthenticatorError, MSG_INVALID_TOKEN if token.nil? || token.to_s.strip.empty?
|
26
22
|
|
27
|
-
puts "TOKEN: #{token}"
|
28
|
-
|
29
23
|
users = _query_user(token: token)
|
30
24
|
raise AuthenticatorError, MSG_INVALID_TOKEN unless users.is_a?(Array) && users.any?
|
31
25
|
|
32
|
-
puts "FOUND USER!"
|
33
|
-
|
34
26
|
user = users.first
|
35
27
|
raise AuthenticatorError, MSG_INACTIVE_USER unless user['active']
|
36
28
|
|
@@ -58,34 +50,23 @@ puts "FOUND USER!"
|
|
58
50
|
AND i.identifier_scheme_id IN (SELECT sch.id FROM identifier_schemes sch WHERE sch.name = 'orcid')
|
59
51
|
WHERE users.api_token = :token
|
60
52
|
SQL
|
61
|
-
|
62
|
-
puts sql
|
63
|
-
|
64
53
|
users = ActiveRecord::Base.simple_execute(sql, token: token.to_s.strip)
|
65
54
|
end
|
66
55
|
|
67
56
|
# Convert the ActiveRecord query results into a JSON object
|
68
57
|
def _serialize_user(user:)
|
69
|
-
|
70
|
-
puts "DB RESULTS:"
|
71
|
-
puts user
|
72
|
-
|
73
58
|
return {} if user.nil? || user['email'].nil?
|
74
59
|
|
75
60
|
hash = {
|
76
61
|
name: [user['surname'], user['firstname']].join(', '),
|
77
62
|
mbox: user['email'],
|
78
|
-
admin: !user['
|
63
|
+
admin: !user['perm'].nil?
|
79
64
|
}
|
80
65
|
hash[:user_id] = { type: 'orcid', identifier: user['orcid'] } unless user['orcid'].nil?
|
81
66
|
return hash if user['org_name'].nil?
|
82
67
|
|
83
68
|
hash[:affiliation] = { name: user.fetch('ror_name', user['org_name']) }
|
84
69
|
hash[:affiliation][:affiliation_id] = { type: 'ror', identifier: user['ror_id'] } unless user['ror_id'].nil?
|
85
|
-
|
86
|
-
puts "HASH:"
|
87
|
-
puts hash
|
88
|
-
|
89
70
|
JSON.parse(hash.to_json)
|
90
71
|
end
|
91
72
|
end
|
data/lib/uc3-dmp-rds/version.rb
CHANGED