authify-api 0.3.3 → 0.4.0

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
  SHA1:
3
- metadata.gz: ee72e82c5e6c776b0cfc07e62c480ef59ecf24fe
4
- data.tar.gz: b3dfd57c8aefb052282db076a842d15d6d75dbae
3
+ metadata.gz: 14d6a59892c799848cfafc2560f6c8a563d47931
4
+ data.tar.gz: ac147175656a4ba68993aa277a08a54636dd5fd6
5
5
  SHA512:
6
- metadata.gz: 1fa30f55edc35e440b3d64522252d28fb90aee4c7b5e3d4c5a5a2df17d9c8e447db3083d8f314d80d01e3054ea1e852ecdd088d9b3fbdeb75e2da9618671f47a
7
- data.tar.gz: 9695fdfe722fc53c3cd7741cbfdde9767acbe0c0c8981c77140a926b44f3f34e3db34d43df34b1e9211c77880942fc23d56ef21bc9ebe92d1f9455f748831bc1
6
+ metadata.gz: d70a5903b23f8cd25965bba23345a61d1a076eae15187ff79882131d0b7c1a408ffb08708d90e6ca84a60762327b6354ed59647b4032d7592f63ca18a48176fc
7
+ data.tar.gz: 9eb2b416d3ce781d6f1abd6891790ab359bfda9aff40adee30ebc72b4f775a551116cc121dcd21f4b99714b80ef5a91862042bd4d286f5656015fcceb495c56b
data/.rubocop.yml CHANGED
@@ -4,6 +4,9 @@ Metrics/LineLength:
4
4
  Metrics/ClassLength:
5
5
  Max: 150
6
6
 
7
+ Metrics/ModuleLength:
8
+ Max: 150
9
+
7
10
  Metrics/AbcSize:
8
11
  Max: 22
9
12
 
@@ -3,6 +3,18 @@ module Authify
3
3
  module Controllers
4
4
  User = proc do
5
5
  helpers do
6
+ def before_index
7
+ params[:fields] = only_indexable_fields
8
+ end
9
+
10
+ def before_show_many
11
+ params[:fields] = only_indexable_fields
12
+ end
13
+
14
+ def before_show
15
+ params[:fields] = only_indexable_fields
16
+ end
17
+
6
18
  def find(id)
7
19
  Models::User.find(id.to_i)
8
20
  end
@@ -19,6 +31,26 @@ module Authify
19
31
  end
20
32
  end
21
33
 
34
+ def indexable_fields
35
+ %i[full-name admin apikeys groups organizations identities].tap do |a|
36
+ if role?(:admin) || role?(:myself)
37
+ a << :verified
38
+ a << :email
39
+ a << :'created-at'
40
+ end
41
+ end
42
+ end
43
+
44
+ def only_indexable_fields
45
+ {
46
+ users: if params[:fields] && params[:fields].key?(:users)
47
+ params[:fields][:users].select { |k, _| indexable_fields.include?(k) }
48
+ else
49
+ indexable_fields
50
+ end
51
+ }
52
+ end
53
+
22
54
  def filtered_attributes(attributes)
23
55
  attributes.select do |k, _v|
24
56
  modifiable_fields.include?(k)
@@ -2,8 +2,8 @@ module Authify
2
2
  module API
3
3
  VERSION = [
4
4
  0, # Major
5
- 3, # Minor
6
- 3 # Patch
5
+ 4, # Minor
6
+ 0 # Patch
7
7
  ].join('.')
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: authify-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Gnagy
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-06-07 00:00:00.000000000 Z
11
+ date: 2017-06-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: authify-core