phcdevworks_accounts_auth0 0.1.0 → 0.4.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/app/controllers/phcdevworks_accounts_auth0/auth/handler_controller.rb +11 -4
- data/app/helpers/phcdevworks_accounts_auth0/application_helper.rb +20 -0
- data/app/views/layouts/phcdevworks_accounts_auth0/components/backend/sidebars/_side_menu.html.erb +12 -2
- data/config/initializers/auth0.rb +1 -1
- data/config/routes.rb +5 -3
- data/lib/phcdevworks_accounts_auth0/version.rb +1 -1
- metadata +2 -3
- data/app/helpers/phcdevworks_accounts_auth0/user/pages_helper.rb +0 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 51eaf99cbd2e95edbe3e8189cdc3bc34eb48f91c8fa7eaa136b3291740bdbe87
|
4
|
+
data.tar.gz: a3ca5c8b66441909e75786896f98a77f6a788925fde242a5001f43475235b89c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 351d8761a9b65a288d8dca1c23af0fe7ebb26454b407e5545e1489bbd6c2b29c798be9c8bec0c90f201566fc5866f990b9851031d0205424d830e07a899add5c
|
7
|
+
data.tar.gz: 90f6c9535d99450db1d7ac6d5d59a6945b217840612fe2d519a240596ec3bc731c314e07c1ebf4162b416c5ab728419c00767a59f4ea73a29e77a17fb8cf049b
|
@@ -4,26 +4,33 @@ module PhcdevworksAccountsAuth0
|
|
4
4
|
def callback
|
5
5
|
auth_info = request.env['omniauth.auth']
|
6
6
|
session[:userinfo] = auth_info['extra']['raw_info']
|
7
|
-
redirect_to '/user
|
7
|
+
redirect_to '/user'
|
8
8
|
end
|
9
9
|
|
10
10
|
def failure
|
11
|
-
# Failed Authentication
|
12
11
|
@error_msg = request.params['message']
|
13
12
|
end
|
14
13
|
|
15
14
|
def logout
|
16
|
-
# Logout
|
17
15
|
reset_session
|
18
16
|
redirect_to logout_url
|
19
17
|
end
|
20
18
|
|
19
|
+
private
|
20
|
+
|
21
|
+
AUTH0_CONFIG = Rails.application.config_for(:auth0)
|
22
|
+
|
21
23
|
def logout_url
|
22
24
|
request_params = {
|
23
25
|
returnTo: root_url,
|
24
26
|
client_id: AUTH0_CONFIG['auth0_client_id']
|
25
27
|
}
|
26
|
-
|
28
|
+
|
29
|
+
URI::HTTPS.build(host: AUTH0_CONFIG['auth0_domain'], path: '/v2/logout', query: to_query(request_params)).to_s
|
30
|
+
end
|
31
|
+
|
32
|
+
def to_query(hash)
|
33
|
+
hash.map { |k, v| "#{k}=#{CGI.escape(v)}" unless v.nil? }.reject(&:nil?).join('&')
|
27
34
|
end
|
28
35
|
|
29
36
|
end
|
@@ -1,6 +1,26 @@
|
|
1
1
|
module PhcdevworksAccountsAuth0
|
2
2
|
module ApplicationHelper
|
3
3
|
|
4
|
+
def user_signed_in?
|
5
|
+
session['userinfo'].present?
|
6
|
+
end
|
7
|
+
|
8
|
+
def authenticate_user!
|
9
|
+
if user_signed_in?
|
10
|
+
@current_user = session['userinfo']
|
11
|
+
else
|
12
|
+
redirect_to root_path
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def current_user
|
17
|
+
@current_user
|
18
|
+
end
|
19
|
+
|
20
|
+
def reset_session
|
21
|
+
session['userinfo'] = nil if session['userinfo'].present?
|
22
|
+
end
|
23
|
+
|
4
24
|
def current_user
|
5
25
|
@current_user = session['userinfo']
|
6
26
|
end
|
data/app/views/layouts/phcdevworks_accounts_auth0/components/backend/sidebars/_side_menu.html.erb
CHANGED
@@ -8,12 +8,22 @@
|
|
8
8
|
<a href="javascript:;" class="menu-profile-link" data-toggle="app-sidebar-profile" data-target="#appSidebarProfileMenu">
|
9
9
|
<div class="menu-profile-cover with-shadow"></div>
|
10
10
|
<div class="menu-profile-image">
|
11
|
-
|
11
|
+
<% if defined?phcdevworks_accounts_devise %>
|
12
|
+
<%= image_tag current_user.gravatar_url %>
|
13
|
+
<% end %>
|
14
|
+
<% if defined?phcdevworks_accounts_auth0 %>
|
15
|
+
|
16
|
+
<% end %>
|
12
17
|
</div>
|
13
18
|
<div class="menu-profile-info">
|
14
19
|
<div class="d-flex align-items-center">
|
15
20
|
<div class="flex-grow-1">
|
16
|
-
|
21
|
+
<% if defined?phcdevworks_accounts_devise %>
|
22
|
+
<%= current_user.firstname + " " + current_user.lastname %>
|
23
|
+
<% end %>
|
24
|
+
<% if defined?phcdevworks_accounts_auth0 %>
|
25
|
+
<%= current_user.name %>
|
26
|
+
<% end %>
|
17
27
|
</div>
|
18
28
|
<div class="menu-caret ms-auto"></div>
|
19
29
|
</div>
|
data/config/routes.rb
CHANGED
@@ -5,8 +5,10 @@ PhcdevworksAccountsAuth0::Engine.routes.draw do
|
|
5
5
|
match "user/profile", to: "user/pages#profile", via: "get"
|
6
6
|
|
7
7
|
# Auth Routes
|
8
|
-
get
|
9
|
-
get
|
10
|
-
get
|
8
|
+
get "/auth/", as: "authentication"
|
9
|
+
get "/auth/callback" => "auth/handler#callback"
|
10
|
+
get "/auth/failure" => "auth/handler#failure"
|
11
|
+
get "/auth/logout" => "auth/handler#logout"
|
12
|
+
get "/auth/redirect" => "auth/handler#redirect"
|
11
13
|
|
12
14
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: phcdevworks_accounts_auth0
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- PHCDevworks
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2022-09-
|
12
|
+
date: 2022-09-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -337,7 +337,6 @@ files:
|
|
337
337
|
- app/controllers/phcdevworks_accounts_auth0/auth/handler_controller.rb
|
338
338
|
- app/controllers/phcdevworks_accounts_auth0/user/pages_controller.rb
|
339
339
|
- app/helpers/phcdevworks_accounts_auth0/application_helper.rb
|
340
|
-
- app/helpers/phcdevworks_accounts_auth0/user/pages_helper.rb
|
341
340
|
- app/jobs/phcdevworks_accounts_auth0/application_job.rb
|
342
341
|
- app/mailers/phcdevworks_accounts_auth0/application_mailer.rb
|
343
342
|
- app/models/phcdevworks_accounts_auth0/application_record.rb
|