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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 12d1d6576ea3620ee8bf943382a260531b6193a39141173698fd5e70f8fccca9
4
- data.tar.gz: '08c112afc6771fa199222358eeb09f7d45821f92775875b639fd0c2d91fc2dbe'
3
+ metadata.gz: 8c7dc9613b8b085518716b38449b3855839b813d28083fbd2c313eae06513604
4
+ data.tar.gz: def9b1adf267154ee846e3c9a66b465e6f7f0b3e02c7d6c8845542d4f5f36d0c
5
5
  SHA512:
6
- metadata.gz: 7d73bf4e5172eee22e80101d452ed41ff9bb3873abff75f90be4f39bd8b858adb8b46f901f1fb4e552a1f3e7a5a1f8f1c3ea04803c021d180bb9a1f04d7ff72f
7
- data.tar.gz: a68f4ed811d8af5920c369c23a4452467a092a56aeec302e732cee594065cb439bacc0bbcd6c755fcb78b6cde81d3fd9923c0e8de7af6b09b1bbb3bc6cd93bf1
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['perm_name'].nil?
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Uc3DmpRds
4
- VERSION = '0.0.17'
4
+ VERSION = '0.0.19'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uc3-dmp-rds
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.17
4
+ version: 0.0.19
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Riley