uc3-dmp-rds 0.0.17 → 0.0.19
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/uc3-dmp-rds/authenticator.rb +2 -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: 8c7dc9613b8b085518716b38449b3855839b813d28083fbd2c313eae06513604
|
4
|
+
data.tar.gz: def9b1adf267154ee846e3c9a66b465e6f7f0b3e02c7d6c8845542d4f5f36d0c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: be45489cb244cff9f7e2e5c7094b393a21006708f2e8276ae64ae4894a8fc9ddf6a2cf0b44a58064065f5b9da963ba5bb0f1068213d12b565f321da76a655f09
|
7
|
+
data.tar.gz: 3d9977589dea3a7d13180221f9ddd3fc6413ceb21e6f210fc1cc944a5103023c165a6058422d91330f2c08238dcf7560028259f17d3910656e38854a476768d4
|
@@ -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,24 @@ 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?,
|
64
|
+
active: user.fetch('active', false)
|
79
65
|
}
|
80
66
|
hash[:user_id] = { type: 'orcid', identifier: user['orcid'] } unless user['orcid'].nil?
|
81
67
|
return hash if user['org_name'].nil?
|
82
68
|
|
83
69
|
hash[:affiliation] = { name: user.fetch('ror_name', user['org_name']) }
|
84
70
|
hash[:affiliation][:affiliation_id] = { type: 'ror', identifier: user['ror_id'] } unless user['ror_id'].nil?
|
85
|
-
|
86
|
-
puts "HASH:"
|
87
|
-
puts hash
|
88
|
-
|
89
71
|
JSON.parse(hash.to_json)
|
90
72
|
end
|
91
73
|
end
|
data/lib/uc3-dmp-rds/version.rb
CHANGED