This repository has been archived by the owner on Apr 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Setup omniauth login with sample 'developer' provider
- Loading branch information
Tom Sabin
committed
Jul 6, 2018
1 parent
e4e2fb5
commit 0284c68
Showing
7 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,7 @@ | ||
class ApplicationController < ActionController::Base | ||
helper_method :user_signed_in? | ||
|
||
def user_signed_in? | ||
session[:current_user].present? | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
class SessionsController < ApplicationController | ||
skip_before_action :verify_authenticity_token, only: :create | ||
|
||
def create | ||
session[:current_user] = { | ||
name: auth_hash.info.name, | ||
email: auth_hash.info.email | ||
} | ||
|
||
redirect_to root_path | ||
end | ||
|
||
protected | ||
|
||
def auth_hash | ||
request.env['omniauth.auth'] | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
OmniAuth.config.logger = Rails.logger | ||
|
||
Rails.application.config.middleware.use OmniAuth::Builder do | ||
provider :developer | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,6 @@ | |
resources :stuffs | ||
|
||
root 'stuffs#index' | ||
|
||
post '/auth/:provider/callback', to: 'sessions#create' | ||
end |