uc3-dmp-rds 0.0.14 → 0.0.15

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: 2c9f10b6b78954c6bdeef8a1bc50443c634c8c571bdfe9aac7bc4d923f00c508
4
- data.tar.gz: eee363480691189deca29ce254a2e0df7fbb6221d93c1de3d66f99e993bc8c52
3
+ metadata.gz: ab8baeefeaefa3440ab7fd1dd17f82597e3a0bdebf56ca00a204cab9fee9fdb0
4
+ data.tar.gz: 6517005d0c6dee5e89274063811ecc73e8f97f25e6e363ed807c4fd2d05d267f
5
5
  SHA512:
6
- metadata.gz: e51984f58f45f27f50313f48c3a055ea45eb9259d9928bc8d362b0823f4e290d3c64e136a8aff913c1c68788eb4787e96886fc5760fd896d9be0a5bacc554060
7
- data.tar.gz: 0ee0de19a875ef4e317d817e9dbf14ade1e3be187297de10caa315d9d3059e3d6e7bd00d710329621f16e204933bc7ae9a5aa216d07e04a61eb4974fbbcc9aaa
6
+ metadata.gz: f82f8dcd0237f542278a0a296a2a4aac96cc99c50455eae77e66e192cc4b64b451d4bb5fa5b2bca8c38fd3d12bd906c17d0b0a2bb7d309d83b30d4ccbaf7d624
7
+ data.tar.gz: edcda33c09cef2fae6de7a85cf345c4cd75a915b7575830096d22f7e7fe876ee829b402519003c72f1f3dfc07d340c14c6cb1b753d675b8ee68bd569b9975eac
@@ -19,9 +19,13 @@ module Uc3DmpRds
19
19
  def authenticate(token:)
20
20
  raise AuthenticatorError, MSG_INVALID_TOKEN if token.nil? || token.to_s.strip.empty?
21
21
 
22
+ puts "TOKEN: #{token}"
23
+
22
24
  users = _query_user(token: token)
23
25
  raise AuthenticatorError, MSG_INVALID_TOKEN unless users.is_a?(Array) && users.any?
24
26
 
27
+ puts "FOUND USER!"
28
+
25
29
  user = users.first
26
30
  raise AuthenticatorError, MSG_INACTIVE_USER unless user['active']
27
31
 
@@ -36,11 +40,11 @@ module Uc3DmpRds
36
40
 
37
41
  sql = <<~SQL.squish
38
42
  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
43
+ orgs.name org_name, ro.name ror_name, ro.ror_id,
44
+ (SELECT perms.name FROM users_perms up LEFT OUTER JOIN perms ON up.perm_id = perms.id
45
+ WHERE users.id = up.user_id AND perms.name = 'modify_templates') perm
40
46
  FROM users
41
47
  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
48
  LEFT OUTER JOIN registry_orgs ro
45
49
  ON orgs.id = ro.org_id
46
50
  LEFT OUTER JOIN identifiers i
@@ -48,13 +52,19 @@ module Uc3DmpRds
48
52
  AND i.identifiable_type = 'User'
49
53
  AND i.identifier_scheme_id IN (SELECT sch.id FROM identifier_schemes sch WHERE sch.name = 'orcid')
50
54
  WHERE users.api_token = :token
51
- LIMIT 1
52
55
  SQL
56
+
57
+ puts sql
58
+
53
59
  users = ActiveRecord::Base.simple_execute(sql, token: token.to_s.strip)
54
60
  end
55
61
 
56
62
  # Convert the ActiveRecord query results into a JSON object
57
63
  def _serialize_user(user:)
64
+
65
+ puts "DB RESULTS:"
66
+ puts user
67
+
58
68
  return {} if user.nil? || user['mbox'].nil?
59
69
 
60
70
  hash = {
@@ -67,7 +77,11 @@ module Uc3DmpRds
67
77
 
68
78
  hash[:affiliation] = { name: user.fetch('ror_name', user['org_name']) }
69
79
  hash[:affiliation][:affiliation_id] = { type: 'ror', identifier: user['ror_id'] } unless user['ror_id'].nil?
70
- hash.to_json
80
+
81
+ puts "HASH:"
82
+ puts hash
83
+
84
+ hash
71
85
  end
72
86
  end
73
87
  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.15'
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.15
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