1
0
mirror of https://github.com/danbee/my-images synced 2025-03-04 08:49:05 +00:00

Switch to GitHub for auth

This commit is contained in:
Daniel Barber 2018-08-07 18:23:07 -04:00
parent ff1e08b46c
commit 021b93aa21
Signed by: danbarber
GPG Key ID: 931D8112E0103DD8
6 changed files with 26 additions and 68 deletions

View File

@ -1,2 +1,2 @@
export TWITTER_KEY=key export GITHUB_KEY=[key]
export TWITTER_SECRET=secret export GITHUB_SECRET=[secret]

View File

@ -4,7 +4,7 @@ gem "rails", "5.2.0"
gem "dragonfly" gem "dragonfly"
gem "jquery-rails" gem "jquery-rails"
gem "omniauth-twitter" gem "omniauth-github"
gem "puma" gem "puma"
gem "sass-rails" gem "sass-rails"
gem "simple_form" gem "simple_form"

View File

@ -70,6 +70,8 @@ GEM
rack (>= 1.3) rack (>= 1.3)
erubi (1.7.1) erubi (1.7.1)
execjs (2.7.0) execjs (2.7.0)
faraday (0.12.2)
multipart-post (>= 1.2, < 3)
ffi (1.9.25) ffi (1.9.25)
globalid (0.4.1) globalid (0.4.1)
activesupport (>= 4.2.0) activesupport (>= 4.2.0)
@ -80,6 +82,7 @@ GEM
rails-dom-testing (>= 1, < 3) rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0) railties (>= 4.2.0)
thor (>= 0.14, < 2.0) thor (>= 0.14, < 2.0)
jwt (1.5.6)
loofah (2.2.2) loofah (2.2.2)
crass (~> 1.0.2) crass (~> 1.0.2)
nokogiri (>= 1.5.9) nokogiri (>= 1.5.9)
@ -93,19 +96,26 @@ GEM
mini_portile2 (2.3.0) mini_portile2 (2.3.0)
minitest (5.11.3) minitest (5.11.3)
multi_json (1.13.1) multi_json (1.13.1)
multi_xml (0.6.0)
multipart-post (2.0.0)
nio4r (2.3.1) nio4r (2.3.1)
nokogiri (1.8.4) nokogiri (1.8.4)
mini_portile2 (~> 2.3.0) mini_portile2 (~> 2.3.0)
oauth (0.5.4) oauth2 (1.4.0)
faraday (>= 0.8, < 0.13)
jwt (~> 1.0)
multi_json (~> 1.3)
multi_xml (~> 0.5)
rack (>= 1.2, < 3)
omniauth (1.8.1) omniauth (1.8.1)
hashie (>= 3.4.6, < 3.6.0) hashie (>= 3.4.6, < 3.6.0)
rack (>= 1.6.2, < 3) rack (>= 1.6.2, < 3)
omniauth-oauth (1.1.0) omniauth-github (1.3.0)
oauth omniauth (~> 1.5)
omniauth (~> 1.0) omniauth-oauth2 (>= 1.4.0, < 2.0)
omniauth-twitter (1.4.0) omniauth-oauth2 (1.5.0)
omniauth-oauth (~> 1.1) oauth2 (~> 1.1)
rack omniauth (~> 1.2)
pry (0.11.3) pry (0.11.3)
coderay (~> 1.1.0) coderay (~> 1.1.0)
method_source (~> 0.9.0) method_source (~> 0.9.0)
@ -206,7 +216,7 @@ DEPENDENCIES
capybara capybara
dragonfly dragonfly
jquery-rails jquery-rails
omniauth-twitter omniauth-github
pry pry
puma puma
rails (= 5.2.0) rails (= 5.2.0)

View File

@ -1 +1 @@
<%= link_to 'Sign in with Twitter', '/auth/twitter' %> <%= link_to 'Sign in with GitHub', '/auth/github' %>

View File

@ -1,3 +1,3 @@
Rails.application.config.middleware.use OmniAuth::Builder do Rails.application.config.middleware.use OmniAuth::Builder do
provider :twitter, ENV['TWITTER_KEY'], ENV['TWITTER_SECRET'] provider :github, ENV["GITHUB_KEY"], ENV["GITHUB_SECRET"]
end end

View File

@ -1,62 +1,10 @@
MyImages::Application.routes.draw do MyImages::Application.routes.draw do
# The priority is based upon order of creation: first created -> highest priority. root "home#index"
# See how all your routes lay out with "rake routes".
root 'home#index' resource :session, only: %i[new destroy]
get "/auth/:provider/callback", to: "sessions#create", as: :create_session
resource :session, only: [:new, :destroy]
get '/auth/:provider/callback', to: 'sessions#create', as: :create_session
resource :user do resource :user do
resources :images resources :images
end end
# Example of regular route:
# get 'products/:id' => 'catalog#view'
# Example of named route that can be invoked with purchase_url(id: product.id)
# get 'products/:id/purchase' => 'catalog#purchase', as: :purchase
# Example resource route (maps HTTP verbs to controller actions automatically):
# resources :products
# Example resource route with options:
# resources :products do
# member do
# get 'short'
# post 'toggle'
# end
#
# collection do
# get 'sold'
# end
# end
# Example resource route with sub-resources:
# resources :products do
# resources :comments, :sales
# resource :seller
# end
# Example resource route with more complex sub-resources:
# resources :products do
# resources :comments
# resources :sales do
# get 'recent', on: :collection
# end
# end
# Example resource route with concerns:
# concern :toggleable do
# post 'toggle'
# end
# resources :posts, concerns: :toggleable
# resources :photos, concerns: :toggleable
# Example resource route within a namespace:
# namespace :admin do
# # Directs /admin/products/* to Admin::ProductsController
# # (app/controllers/admin/products_controller.rb)
# resources :products
# end
end end