kadmin 1.0.3 → 1.0.4

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: 51c3cae4ed7c833aa663c74fa0ab036f3976c273869df2613721499d4d297d12
4
- data.tar.gz: ddf52353bb65ec10d8865ad6e18535d4dcf02bdb7dfbfd93f8da6405f6f4ccf6
3
+ metadata.gz: b3aa3a7daa8c814970c094dc05160e8d8fa64abd57141bc784078e4022802c34
4
+ data.tar.gz: 754a7866c1f92826a4f3ddf194a1bf368524b3815fc5837369fe8f304afd3817
5
5
  SHA512:
6
- metadata.gz: 4237584dd64f1e5c1f76adb2c1f1b465075742a12b05786e62f46a5f77b8b54e35cc99d38f68289d6f3b5e41e85998c7486580e1e98491c763ea4de79670586a
7
- data.tar.gz: 5529f972678b909a6288796de6c0b8c829412c8835df306040ccf109961f061d55c56e77139a15cd8decc57096175c68a7da17f414da489618f0e1d6422e1eaf
6
+ metadata.gz: 9e740d139e1adf2a4484abf74f098e6862a23b544a4bd29d4ae45e139c2d9382498c0e9688469e0a616cb520f318926fe253ea40122d870ace04c2cc5d55a4ac
7
+ data.tar.gz: b12534a69b80d530b9a604e2f00fb776c869b95e3cecd3b693a28c765d5c5cb28a896c05490d530179d9aa43179f7fc996a4e0666ba05be105d51a4292c10598
@@ -22,7 +22,7 @@
22
22
  <div class="header-block header-block-nav">
23
23
  <ul class="nav-profile">
24
24
  <% if logged_in? %>
25
- <li><%= authorized_user.organization %></li>
25
+ <li style="padding-right: 10px;"><%= authorized_user.organization %></li>
26
26
  <li><%= link_to(t('kadmin.authorization.logout'), Kadmin::Engine.routes.url_helpers.auth_logout_path) %></li>
27
27
  <% end %>
28
28
  </ul>
@@ -1,9 +1,17 @@
1
1
  module Kadmin
2
2
  module Auth
3
3
  class UserStore
4
- def initialize
4
+ def initialize(path = nil)
5
5
  @store = {}
6
- load_users!
6
+
7
+ path ||= Rails.root.join('config', 'admin_users.yml')
8
+ if File.exist?(path) && File.readable?(path)
9
+ definitions = YAML.load_file(path.to_s)
10
+ create_organizations(definitions['organizations'])
11
+ load_users(definitions['users'])
12
+ else
13
+ Rails.logger.warn("Can't read admin users auth file at #{file}. Auth might not work")
14
+ end
7
15
  end
8
16
 
9
17
  def get(email)
@@ -18,25 +26,26 @@ module Kadmin
18
26
  @store.key?(email.to_s.downcase)
19
27
  end
20
28
 
21
- def load_users!
22
- file = Rails.root.join('config', 'admin_users.yml')
23
- if File.exist?(file) && File.readable?(file)
24
- definitions = YAML.load_file(file.to_s)
25
- definitions.each do |definition|
26
- email = definition['email']
27
- options = {
28
- admin: definition.fetch('admin', false),
29
- accept: Array.wrap(definition.fetch('accept', [])).map(&:to_sym),
30
- organization: definition.fetch('organization', 'offerista') # default organization, needs to exist in DB
31
- }
32
-
33
- set(email, Kadmin::Auth.config.user_class.new(email, **options))
34
- end
35
- else
36
- Rails.logger.warn("Can't read admin users auth file at #{file}. Auth might not work")
29
+ private
30
+
31
+ def load_users(users)
32
+ users.each do |user|
33
+ email = user['email']
34
+ options = {
35
+ admin: user.fetch('admin', false),
36
+ accept: Array.wrap(user.fetch('accept', [])).map(&:to_sym),
37
+ organization: user.fetch('organization', 'offerista') # default organization, needs to exist in DB
38
+ }
39
+
40
+ set(email, Kadmin::Auth.config.user_class.new(email, **options))
41
+ end
42
+ end
43
+
44
+ def create_organizations(organizations)
45
+ organizations.each do |organization|
46
+ Kadmin::Organization.find_or_create_by(name: organization)
37
47
  end
38
48
  end
39
- private :load_users!
40
49
  end
41
50
  end
42
51
  end
@@ -1,3 +1,3 @@
1
1
  module Kadmin
2
- VERSION = '1.0.3'.freeze
2
+ VERSION = '1.0.4'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kadmin
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nicolas Pepin-Perreault
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2018-10-16 00:00:00.000000000 Z
13
+ date: 2018-11-08 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails
@@ -196,7 +196,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
196
196
  version: '0'
197
197
  requirements: []
198
198
  rubyforge_project:
199
- rubygems_version: 2.7.6
199
+ rubygems_version: 2.7.8
200
200
  signing_key:
201
201
  specification_version: 4
202
202
  summary: Collection of utility, configuration, etc., for admin areas