uc3-dmp-rds 0.0.14 → 0.0.16

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2c9f10b6b78954c6bdeef8a1bc50443c634c8c571bdfe9aac7bc4d923f00c508
4
- data.tar.gz: eee363480691189deca29ce254a2e0df7fbb6221d93c1de3d66f99e993bc8c52
3
+ metadata.gz: f5a1eef3f03371fe98e76dabd04387f03c8d141fb30782ab660c3ef098e6a4e9
4
+ data.tar.gz: 1823a9005c68985f6f3af990f41255fecd21bf344987e4f9c150aa4873accf04
5
5
  SHA512:
6
- metadata.gz: e51984f58f45f27f50313f48c3a055ea45eb9259d9928bc8d362b0823f4e290d3c64e136a8aff913c1c68788eb4787e96886fc5760fd896d9be0a5bacc554060
7
- data.tar.gz: 0ee0de19a875ef4e317d817e9dbf14ade1e3be187297de10caa315d9d3059e3d6e7bd00d710329621f16e204933bc7ae9a5aa216d07e04a61eb4974fbbcc9aaa
6
+ metadata.gz: 91bb16e36bec17bff2a6cf257d279b59672c9c6ad30b6c779291c53ea5611fba8ea668455d720e9d924f0376b900f333ae84f3b8b85391ed6b431371dd555371
7
+ data.tar.gz: 18222b1957ef9b5466e745673cff35a1e9fbe502f5a9facb5947b9aeefdc2d96a9f9f4454831a2938a223c03d4f5315ef297464a683273d90b35dccf7d909872
@@ -17,11 +17,19 @@ module Uc3DmpRds
17
17
  # Look up the user based on the API token. Will fail if Uc3DmpRds::Adapter does not
18
18
  # have an established connection!
19
19
  def authenticate(token:)
20
+
21
+ puts "Authenticator called"
22
+
23
+
20
24
  raise AuthenticatorError, MSG_INVALID_TOKEN if token.nil? || token.to_s.strip.empty?
21
25
 
26
+ puts "TOKEN: #{token}"
27
+
22
28
  users = _query_user(token: token)
23
29
  raise AuthenticatorError, MSG_INVALID_TOKEN unless users.is_a?(Array) && users.any?
24
30
 
31
+ puts "FOUND USER!"
32
+
25
33
  user = users.first
26
34
  raise AuthenticatorError, MSG_INACTIVE_USER unless user['active']
27
35
 
@@ -36,11 +44,11 @@ module Uc3DmpRds
36
44
 
37
45
  sql = <<~SQL.squish
38
46
  SELECT users.firstname, users.surname, users.email, users.active, i.value orcid,
39
- orgs.name org_name, ro.name ror_name, ro.ror_id, perms.name perm_name
47
+ orgs.name org_name, ro.name ror_name, ro.ror_id,
48
+ (SELECT perms.name FROM users_perms up LEFT OUTER JOIN perms ON up.perm_id = perms.id
49
+ WHERE users.id = up.user_id AND perms.name = 'modify_templates') perm
40
50
  FROM users
41
51
  INNER JOIN orgs ON users.org_id = orgs.id
42
- LEFT OUTER JOIN users_perms up ON users.id = up.user_id
43
- LEFT OUTER JOIN perms ON up.perm_id = perms.id AND perms.name = 'modify_templates'
44
52
  LEFT OUTER JOIN registry_orgs ro
45
53
  ON orgs.id = ro.org_id
46
54
  LEFT OUTER JOIN identifiers i
@@ -48,13 +56,19 @@ module Uc3DmpRds
48
56
  AND i.identifiable_type = 'User'
49
57
  AND i.identifier_scheme_id IN (SELECT sch.id FROM identifier_schemes sch WHERE sch.name = 'orcid')
50
58
  WHERE users.api_token = :token
51
- LIMIT 1
52
59
  SQL
60
+
61
+ puts sql
62
+
53
63
  users = ActiveRecord::Base.simple_execute(sql, token: token.to_s.strip)
54
64
  end
55
65
 
56
66
  # Convert the ActiveRecord query results into a JSON object
57
67
  def _serialize_user(user:)
68
+
69
+ puts "DB RESULTS:"
70
+ puts user
71
+
58
72
  return {} if user.nil? || user['mbox'].nil?
59
73
 
60
74
  hash = {
@@ -67,7 +81,11 @@ module Uc3DmpRds
67
81
 
68
82
  hash[:affiliation] = { name: user.fetch('ror_name', user['org_name']) }
69
83
  hash[:affiliation][:affiliation_id] = { type: 'ror', identifier: user['ror_id'] } unless user['ror_id'].nil?
70
- hash.to_json
84
+
85
+ puts "HASH:"
86
+ puts hash
87
+
88
+ hash
71
89
  end
72
90
  end
73
91
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Uc3DmpRds
4
- VERSION = '0.0.14'
4
+ VERSION = '0.0.16'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uc3-dmp-rds
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.14
4
+ version: 0.0.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Riley
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-05-25 00:00:00.000000000 Z
11
+ date: 2023-05-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_record_simple_execute