uc3-dmp-rds 0.0.16 → 0.0.18

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