auth1 0.2.0 → 0.3.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 +4 -4
- data/MIT-LICENSE +1 -1
- data/README.md +21 -4
- data/app/helpers/auth1/sessions_helper.rb +33 -1
- data/lib/auth1/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3b3ad616013e8575d0698b0459572d51a2516a2846237709d1713edd4e7bbec6
|
4
|
+
data.tar.gz: f37fdd081a5955d1749cd22290d784ae05f9ef3a4496d6044de589ed29e9313d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2d1d686fa3c33118f860cff7ae134ce1599e88c18af4faadf813d4a44af47bbe860df9ab5e0a289dd383002c57906a28c313562e102e8a047bd6632bc34ed8bb
|
7
|
+
data.tar.gz: 4ad7674a96035d9d38bad4fec498a6a1376c727ff8fcc5081aceded3961eb20d860f9ba8736187b6df6caa5f22b04c365a8e82ca2bad076388f4e9145b734a47
|
data/MIT-LICENSE
CHANGED
data/README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# Auth1
|
2
|
-
|
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
|
-
|
19
|
+
Set the following environment variables with the values from [Auth0 Application Settings](https://manage.auth0.com/#/applications):
|
20
20
|
```bash
|
21
|
-
|
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://
|
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?
|
38
|
+
session['userinfo'].present?
|
7
39
|
end
|
8
40
|
end
|
9
41
|
end
|
data/lib/auth1/version.rb
CHANGED