tiny_auth 1.0.0 → 2.0.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
- SHA1:
3
- metadata.gz: ab849294a31f7be0e5da2033ab81e9bd91850e67
4
- data.tar.gz: cd1c89e452847d5b48cf69235c9e0c46f0ecd1ea
2
+ SHA256:
3
+ metadata.gz: ff3ff4ff25d9895b64f12d3e506d3c4ebba61c5c0ba702afc37501aeb13dc956
4
+ data.tar.gz: 6f71e8f393807eb1b5ab944d720982a7b14e4cbb43a00f2ede0f822ad8cb85cc
5
5
  SHA512:
6
- metadata.gz: 399030a4ad8844703aee70fa18185fc36f65e566941a1c8fd01a39c36ebe4773604a4ee270e00a5656153f010e3c6dc0bff02af8c410a01b58a530d7049edf32
7
- data.tar.gz: 63dbff0e1f10d646a14939ba3c6d199860027aae7660657bc9450c90d29c2e4c6b5cc1697637d87bc7ec067d48e075f335a69690bf2208aa3770f88823bf5dd7
6
+ metadata.gz: d8d987c6ca4ef3387d245a9f4e6a263729a928839466617b227db3592d96ffce8605513fbf78f63d33802de18712c36a97b04f8961570a7fb3e57c45e2101341
7
+ data.tar.gz: 72c2cee4eb4bc47dbe50dfa55473d3ae3be6eca231ebbd5581d000c633dfffe204c79493f9171a51087cffa419135ef3392ebe09416623b42c70a569e8787445
data/README.md CHANGED
@@ -56,9 +56,9 @@ Oh, and you can add authentication to your controllers:
56
56
 
57
57
  ```ruby
58
58
  class ApplicationController < ActionController::Base
59
- extend TinyAuth::Controller
59
+ include TinyAuth::Controller.new(model: User)
60
60
 
61
- authenticates model: User
61
+ before_action :authenticate_user
62
62
 
63
63
  def index
64
64
  if user_signed_in?
@@ -1,7 +1,7 @@
1
1
  require "active_support/core_ext/object/blank"
2
2
 
3
3
  module TinyAuth
4
- module Controller
4
+ class Controller < Module
5
5
  # Extract a token from a request
6
6
  # @param request [ActionDispatch::HTTP::Request]
7
7
  # @return [String,nil]
@@ -15,13 +15,12 @@ module TinyAuth
15
15
  # resource.
16
16
  # @param model [ActiveRecord::Base]
17
17
  # @param name [Symbol] Used to define methods like `current_user`
18
- # @param options [Hash] Additional arguments for `before_action`
19
18
  #
20
19
  # @example
21
20
  # class ApplicationController < ActionController::Base
22
- # extend TinyAuth::Controller
21
+ # include TinyAuth::Controller.new(model: User)
23
22
  #
24
- # authenticates model: User, only: :index
23
+ # before_action :authenticate_user
25
24
  #
26
25
  # def index
27
26
  # if user_signed_in?
@@ -31,7 +30,7 @@ module TinyAuth
31
30
  # end
32
31
  # end
33
32
  # end
34
- def authenticates(model:, name: model.model_name.singular, **options)
33
+ def initialize(model:, name: model.model_name.singular)
35
34
  authenticate = :"authenticate_#{name}"
36
35
  current = :"current_#{name}"
37
36
  current_ivar = :"@current_#{name}"
@@ -51,8 +50,6 @@ module TinyAuth
51
50
  instance_variable_set(current_ivar, resource)
52
51
  end
53
52
  end
54
-
55
- before_action(authenticate, **options)
56
53
  end
57
54
  end
58
55
  end
@@ -1,3 +1,3 @@
1
1
  module TinyAuth
2
- VERSION = "1.0.0"
2
+ VERSION = "2.0.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tiny_auth
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ray Zane
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-12-19 00:00:00.000000000 Z
11
+ date: 2020-05-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -164,7 +164,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
164
164
  version: '0'
165
165
  requirements: []
166
166
  rubyforge_project:
167
- rubygems_version: 2.6.14
167
+ rubygems_version: 2.7.6
168
168
  signing_key:
169
169
  specification_version: 4
170
170
  summary: Bare-minimum authentication for APIs