console_utils 0.3.0 → 0.3.1

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
  SHA1:
3
- metadata.gz: edf4a90c287e0a2b35baf4b4b30a5a5205279aba
4
- data.tar.gz: 7ee2964fc56778c17508aaa7f1f754149cc65fd1
3
+ metadata.gz: df3a34e82938cc4b28ff52f9be97353251775365
4
+ data.tar.gz: dcf13ae29e5533b1fd801c7cf083735f52f3ea4a
5
5
  SHA512:
6
- metadata.gz: 2915ca3739fdad30c77ef674c71ace430178c5de0b5be74e49aeadaac7068b847181ae90aed5fc51a6f6f72a6207c7e6222eda7b37ff4bb72e3b45a419df0b24
7
- data.tar.gz: bd9daf266a95ac31b80aed492ba63d40b949067b884d186f690c1a48ec6610b345ace9199266276f60b06dbc6522e0e7e4e5ebf95fb9879954eaa79cd48441b3
6
+ metadata.gz: 90704c63d92a2624db091c79ab47c33150db2cc03c4615804f066aa07482a29c284a2006b0f5e30ef0286d49db9264800da02d2dedf4b7e0e1b712924581d88a
7
+ data.tar.gz: 37f81f3c16fe2f2d9b9ec4871be36d967b9adce1d74c0c4a81f1bb17f3e5db12c655617d2e84371c69b3ee1f57ba13aa015d0ddf04187dad3496b4a6f8391f09
@@ -1,18 +1,22 @@
1
1
  module ConsoleUtils::RequestUtils
2
2
  class DefaultAuthAutomator
3
3
  def self.call(rq)
4
- rq.params[ConsoleUtils.token_param] ||=
5
- ConsoleUtils.default_token.presence or ConsoleUtils.auto_token_for(rq.uid)
4
+ if rq.can_auto_auth?
5
+ rq.params[ConsoleUtils.token_param] ||=
6
+ ConsoleUtils.default_token.presence or ConsoleUtils.auto_token_for(rq.uid)
7
+ end
6
8
  end
7
9
  end
8
10
 
9
11
  class SimpleTokenAutomator
10
12
  def self.call(rq)
11
- model_key = ConsoleUtils.user_model.model_name.param_key
12
- header_names = ::SimpleTokenAuthentication.header_names[model_key.to_sym]
13
- fields = header_names.keys
14
- user = ConsoleUtils.find_user(rq.uid, scope: ConsoleUtils.user_model.select(:id, *fields))
15
- header_names.each { |field, name| rq.headers[name] ||= user.public_send(field) }
13
+ if rq.can_auto_auth?
14
+ model_key = ConsoleUtils.user_model.model_name.param_key
15
+ header_names = ::SimpleTokenAuthentication.header_names[model_key.to_sym]
16
+ fields = header_names.keys
17
+ user = ConsoleUtils.find_user(rq.uid, scope: ConsoleUtils.user_model.select(:id, *fields))
18
+ header_names.each { |field, name| rq.headers[name] ||= user.public_send(field) }
19
+ end
16
20
  end
17
21
  end
18
22
  end
@@ -13,7 +13,7 @@ module ConsoleUtils::RequestUtils
13
13
 
14
14
  ConsoleUtils.logger.debug { "#{uid}, #{params()}, #{headers()}" }
15
15
 
16
- auth_automator.(self) if can_auto_auth?
16
+ auth_automator.(self)
17
17
  end
18
18
 
19
19
  def params
@@ -1,3 +1,3 @@
1
1
  module ConsoleUtils
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: console_utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anton
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-17 00:00:00.000000000 Z
11
+ date: 2015-08-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport