uc3-dmp-rds 0.0.12 → 0.0.14

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: 702eaad4224de108ac5263d173ffd37b34ca51871cdfc54f0998f06c8782aa5b
4
- data.tar.gz: 7fe595f87d591809e7b9295e438368e26f0d9fc5f71f7891ef223bc094b02b24
3
+ metadata.gz: 2c9f10b6b78954c6bdeef8a1bc50443c634c8c571bdfe9aac7bc4d923f00c508
4
+ data.tar.gz: eee363480691189deca29ce254a2e0df7fbb6221d93c1de3d66f99e993bc8c52
5
5
  SHA512:
6
- metadata.gz: 0e79712aed60f791fa03366ad7abe203d9ac3bbba18c1615113c3027619606081b2806f2b3748eadff50dea47487e9257230de8fc743619b1bacaddb1b86ef53
7
- data.tar.gz: 99014e54e2fb2d97bdbe47950f3f727d75fe9c9d808098fcd1d4c9de830b4a33a8a60e4b7e25c2f9faa3a5657b12d4623bfcd987135f2eb824bb7c9a9dcb83bf
6
+ metadata.gz: e51984f58f45f27f50313f48c3a055ea45eb9259d9928bc8d362b0823f4e290d3c64e136a8aff913c1c68788eb4787e96886fc5760fd896d9be0a5bacc554060
7
+ data.tar.gz: 0ee0de19a875ef4e317d817e9dbf14ade1e3be187297de10caa315d9d3059e3d6e7bd00d710329621f16e204933bc7ae9a5aa216d07e04a61eb4974fbbcc9aaa
@@ -14,17 +14,6 @@ module Uc3DmpRds
14
14
  MSG_INACTIVE_USER = 'User is inactive'
15
15
 
16
16
  class << self
17
- # Retrieves the User API token from the headers
18
- def token_from_headers(headers: {})
19
- return nil unless headers.is_a?(Hash) && headers.keys.any?
20
-
21
- authorization = json.select { |k, _v| k.downcase.strip == 'authorization' }
22
- parts = authorization.split(' ')
23
- return nil unless parts.first.downcase == 'token' && parts.length == 2
24
-
25
- parts.last.strip
26
- end
27
-
28
17
  # Look up the user based on the API token. Will fail if Uc3DmpRds::Adapter does not
29
18
  # have an established connection!
30
19
  def authenticate(token:)
@@ -47,9 +36,11 @@ module Uc3DmpRds
47
36
 
48
37
  sql = <<~SQL.squish
49
38
  SELECT users.firstname, users.surname, users.email, users.active, i.value orcid,
50
- orgs.name org_name, ro.name ror_name, ro.ror_id
39
+ orgs.name org_name, ro.name ror_name, ro.ror_id, perms.name perm_name
51
40
  FROM users
52
41
  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'
53
44
  LEFT OUTER JOIN registry_orgs ro
54
45
  ON orgs.id = ro.org_id
55
46
  LEFT OUTER JOIN identifiers i
@@ -66,7 +57,11 @@ module Uc3DmpRds
66
57
  def _serialize_user(user:)
67
58
  return {} if user.nil? || user['mbox'].nil?
68
59
 
69
- hash = { name: [user['surname'], user['firstname']].join(', '), mbox: user['email'] }
60
+ hash = {
61
+ name: [user['surname'], user['firstname']].join(', '),
62
+ mbox: user['email'],
63
+ admin: !user['perm_name'].nil?
64
+ }
70
65
  hash[:user_id] = { type: 'orcid', identifier: user['orcid'] } unless user['orcid'].nil?
71
66
  return hash.to_json if user['org_name'].nil?
72
67
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Uc3DmpRds
4
- VERSION = '0.0.12'
4
+ VERSION = '0.0.14'
5
5
  end
data/lib/uc3-dmp-rds.rb CHANGED
@@ -2,6 +2,7 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require 'uc3-dmp-rds/adapter'
5
+ require 'uc3-dmp-rds/authenticator'
5
6
 
6
7
  # RDS Database adapter
7
8
  module Uc3DmpRds
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.12
4
+ version: 0.0.14
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-24 00:00:00.000000000 Z
11
+ date: 2023-05-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_record_simple_execute