auth1 0.4.0 → 0.5.0

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
  SHA256:
3
- metadata.gz: 23449d863a7488a869e5b584dbfd6c624d07a57a7b5eaf491900fe4a456b92ef
4
- data.tar.gz: c77439187931a3f410c1d62a117d0f1ff40ce2d5a0a65b9ba1a0d667854edf93
3
+ metadata.gz: 87e31158ba864d33d332a4c8d3f51fc22c6efc40f9b7b152c599853af6a3beed
4
+ data.tar.gz: c374e105ca45b58945e28b9609e2551227d23ba029dc4ff98314cf650c7169ce
5
5
  SHA512:
6
- metadata.gz: b511924b3065485b76e4a0b3eeb1cec655fee5c0f26c9e1bbc4c0b83a24e3cc94d266ef985aa0e41a10e8d38bf3972a1a35ea468c5a4c33826587a3c4cac16b8
7
- data.tar.gz: fd7456d3823a99e120e832c6e73e30a0a0da1d489ec38dd1465e43201253b2c290a030e8aca89e4029955369a325e2ed583fc7f201f7775c666c88268a62354b
6
+ metadata.gz: 6fa02f1713470b70eda1f4cffc1482ae49a797f6520fe8e6786563fefe1a5725703b7dac125d65b951d7eb75805c8240d36cc18d68443b4281b3e2820b40dd3f
7
+ data.tar.gz: ff5ee901c1fbfba45d744d3f99b06a29349aa2a6bbda6bd737366795ae76b88c1fe7c09902858f144bbefed71203075b4b41b85f90fb1d3714d01e0c927f7a07
data/README.md CHANGED
@@ -1,8 +1,33 @@
1
1
  # Auth1
2
- Auth1 is a Rails Engine for Auth0. Auth1 provides everything you need to use [Auth0](https://auth0.com) in your Rails application.
2
+ Auth1 is a [Rails Engine](https://guides.rubyonrails.org/engines.html) for [Auth0](https://auth0.com). Auth1 provides everything you need to use [Auth0](https://auth0.com) in your Rails application.
3
3
 
4
4
  ## Usage
5
- How to use my plugin.
5
+
6
+ ### View Helpers
7
+
8
+ #### Link Helpers
9
+ ```ruby
10
+ <% if user_signed_in? -%>
11
+ <%= logout_link %>
12
+ <% else -%>
13
+ <%= login_link %>
14
+ <% end -%>
15
+
16
+ # or just
17
+ <%= login_or_logout_link %>
18
+ ```
19
+
20
+ #### Button Helpers
21
+ ```ruby
22
+ <% if user_signed_in? -%>
23
+ <%= logout_button %>
24
+ <% else -%>
25
+ <%= login_button %>
26
+ <% end -%>
27
+
28
+ # or just
29
+ <%= login_or_logout_button %>
30
+ ```
6
31
 
7
32
  ## Installation
8
33
  Add this line to your application's Gemfile:
@@ -27,23 +52,10 @@ AUTH0_DOMAIN
27
52
  AUTH0_LOGOUT_URL
28
53
  ```
29
54
 
30
- Update **Allowed Callback URLs** field in [Auth0 Application Settings](https://manage.auth0.com/#/applications). For local development, you can set this value to `http://localhost:3000/auth/auth0/callback`.
55
+ Update **Allowed Callback URLs** field in [Auth0 Application Settings](https://manage.auth0.com/#/applications). For local development, you can set this value to `http://localhost:3000/auth/auth0/callback`git.
31
56
 
32
57
  Update **Allowed Logout URLs** field in [Auth0 Application Settings](https://manage.auth0.com/#/applications) with the same value in `AUTH0_LOGOUT_URL` environment variable.
33
58
 
34
- ## View Helpers
35
-
36
- ```ruby
37
- <% if user_signed_in? -%>
38
- <%= logout_button %>
39
- <% else -%>
40
- <%= login_button %>
41
- <% end -%>
42
-
43
- # or just
44
- <%= login_or_logout_button %>
45
- ```
46
-
47
59
  ## Contributing
48
60
  Contribution directions go here.
49
61
 
@@ -28,11 +28,31 @@ module Auth1
28
28
  end
29
29
  end
30
30
 
31
- def login_link; end
31
+ def login_link(name = 'Login', options = nil, html_options = nil, &block)
32
+ options ||= '/auth/auth0'
33
+ html_options ||= {}
34
+ html_options[:method] = :post
35
+ link_to(name, options, html_options, &block)
36
+ end
32
37
 
33
- def logout_link; end
38
+ def logout_link(name = 'Logout', options = nil, html_options = nil, &block)
39
+ options ||= auth1.logout_path
40
+ html_options ||= {}
41
+ html_options[:method] = :get
42
+ link_to(name, options, html_options, &block)
43
+ end
34
44
 
35
- def login_or_logout_link; end
45
+ def login_or_logout_link(name = %w[Login Logout], options = [nil, nil], html_options = [nil, nil], &block)
46
+ if user_signed_in?
47
+ logout_html_options = html_options[1] || {}
48
+ logout_html_options[:method] = :get
49
+ logout_link(name[1], options[1], logout_html_options, &block)
50
+ else
51
+ login_html_options = html_options[0] || {}
52
+ login_html_options[:method] = :post
53
+ login_link(name[0], options[0], login_html_options, &block)
54
+ end
55
+ end
36
56
 
37
57
  def user_signed_in?
38
58
  session['userinfo'].present?
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Auth1
4
- VERSION = '0.4.0'
4
+ VERSION = '0.5.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: auth1
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joon Lee
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-05 00:00:00.000000000 Z
11
+ date: 2020-04-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: omniauth-auth0