auth1 0.2.0 → 0.3.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
  SHA256:
3
- metadata.gz: 9cbe8220cdce0cc3e9456969eb995ad9bb70425afaef6f5379804806e3e7fe38
4
- data.tar.gz: 4dd79d2768e93420123259e50a0257c45487baeb510f8c054199b66a1ecdd864
3
+ metadata.gz: 3b3ad616013e8575d0698b0459572d51a2516a2846237709d1713edd4e7bbec6
4
+ data.tar.gz: f37fdd081a5955d1749cd22290d784ae05f9ef3a4496d6044de589ed29e9313d
5
5
  SHA512:
6
- metadata.gz: 81187a4a8dc57e6e692e93c2fc0896637ea8dcdfb9686d2dfb2bdd38f6b58db7d1b5e821fe532387bb686fbe5aaa10924ec89236e2d5eb6d50867a483b4f005c
7
- data.tar.gz: a69a4ddeb703bd03beaddbcf7001649e36ec2a5815491e6781cb26a55fa9d59dea81dcabf64a331d52f6d3c4a56e112589a1c158cfe24deed5b04317a37ec48f
6
+ metadata.gz: 2d1d686fa3c33118f860cff7ae134ce1599e88c18af4faadf813d4a44af47bbe860df9ab5e0a289dd383002c57906a28c313562e102e8a047bd6632bc34ed8bb
7
+ data.tar.gz: 4ad7674a96035d9d38bad4fec498a6a1376c727ff8fcc5081aceded3961eb20d860f9ba8736187b6df6caa5f22b04c365a8e82ca2bad076388f4e9145b734a47
data/MIT-LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2020
1
+ Copyright 2020 Joon Lee
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # Auth1
2
- Short description and motivation.
2
+ Auth1 provides everything you need to use Auth0 in your Rails application.
3
3
 
4
4
  ## Usage
5
5
  How to use my plugin.
@@ -16,13 +16,30 @@ And then execute:
16
16
  $ bundle
17
17
  ```
18
18
 
19
- Or install it yourself as:
19
+ Set the following environment variables with the values from [Auth0 Application Settings](https://manage.auth0.com/#/applications):
20
20
  ```bash
21
- $ gem install auth1
21
+ AUTH0_CLIENT_ID
22
+ AUTH0_CLIENT_SECRET
23
+ AUTH0_DOMAIN
24
+ ```
25
+
26
+ 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.
27
+
28
+ ## View Helpers
29
+
30
+ ```ruby
31
+ <% if user_signed_in? -%>
32
+ <%= logout_button %>
33
+ <% else -%>
34
+ <%= login_button %>
35
+ <% end -%>
36
+
37
+ # or just
38
+ <%= login_or_logout_button %>
22
39
  ```
23
40
 
24
41
  ## Contributing
25
42
  Contribution directions go here.
26
43
 
27
44
  ## License
28
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
45
+ The gem is available as open source under the terms of the [MIT License](https://github.com/seouri/auth1/blob/master/MIT-LICENSE).
@@ -2,8 +2,40 @@
2
2
 
3
3
  module Auth1
4
4
  module SessionsHelper
5
+ def login_button(name = 'Login', options = nil, html_options = nil, &block)
6
+ options ||= '/auth/auth0'
7
+ html_options ||= {}
8
+ html_options[:method] = :post
9
+ button_to(name, options, html_options, &block)
10
+ end
11
+
12
+ def logout_button(name = 'Logout', options = nil, html_options = nil, &block)
13
+ options ||= auth1.logout_path
14
+ html_options ||= {}
15
+ html_options[:method] = :get
16
+ button_to(name, options, html_options, &block)
17
+ end
18
+
19
+ def login_or_logout_button(name = %w[Login Logout], options = [nil, nil], html_options = [nil, nil], &block)
20
+ if user_signed_in?
21
+ logout_html_options = html_options[1] || {}
22
+ logout_html_options[:method] = :get
23
+ logout_button(name[1], options[1], logout_html_options, &block)
24
+ else
25
+ login_html_options = html_options[0] || {}
26
+ login_html_options[:method] = :post
27
+ login_button(name[0], options[0], login_html_options, &block)
28
+ end
29
+ end
30
+
31
+ def login_link; end
32
+
33
+ def logout_link; end
34
+
35
+ def login_or_logout_link; end
36
+
5
37
  def user_signed_in?
6
- session['userinfo'].present? && session['userinfo']['uid'].present?
38
+ session['userinfo'].present?
7
39
  end
8
40
  end
9
41
  end
data/lib/auth1/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Auth1
4
- VERSION = '0.2.0'
4
+ VERSION = '0.3.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: auth1
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joon Lee