diff --git a/.envrc.example b/.envrc.example index 62bd92c..fa58188 100644 --- a/.envrc.example +++ b/.envrc.example @@ -1,2 +1,2 @@ -export TWITTER_KEY=key -export TWITTER_SECRET=secret +export GITHUB_KEY=[key] +export GITHUB_SECRET=[secret] diff --git a/Gemfile b/Gemfile index a8c60a0..ac9ac88 100644 --- a/Gemfile +++ b/Gemfile @@ -4,7 +4,7 @@ gem "rails", "5.2.0" gem "dragonfly" gem "jquery-rails" -gem "omniauth-twitter" +gem "omniauth-github" gem "puma" gem "sass-rails" gem "simple_form" diff --git a/Gemfile.lock b/Gemfile.lock index 0b306a0..2287d54 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -70,6 +70,8 @@ GEM rack (>= 1.3) erubi (1.7.1) execjs (2.7.0) + faraday (0.12.2) + multipart-post (>= 1.2, < 3) ffi (1.9.25) globalid (0.4.1) activesupport (>= 4.2.0) @@ -80,6 +82,7 @@ GEM rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) thor (>= 0.14, < 2.0) + jwt (1.5.6) loofah (2.2.2) crass (~> 1.0.2) nokogiri (>= 1.5.9) @@ -93,19 +96,26 @@ GEM mini_portile2 (2.3.0) minitest (5.11.3) multi_json (1.13.1) + multi_xml (0.6.0) + multipart-post (2.0.0) nio4r (2.3.1) nokogiri (1.8.4) 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) hashie (>= 3.4.6, < 3.6.0) rack (>= 1.6.2, < 3) - omniauth-oauth (1.1.0) - oauth - omniauth (~> 1.0) - omniauth-twitter (1.4.0) - omniauth-oauth (~> 1.1) - rack + omniauth-github (1.3.0) + omniauth (~> 1.5) + omniauth-oauth2 (>= 1.4.0, < 2.0) + omniauth-oauth2 (1.5.0) + oauth2 (~> 1.1) + omniauth (~> 1.2) pry (0.11.3) coderay (~> 1.1.0) method_source (~> 0.9.0) @@ -206,7 +216,7 @@ DEPENDENCIES capybara dragonfly jquery-rails - omniauth-twitter + omniauth-github pry puma rails (= 5.2.0) diff --git a/app/views/sessions/new.html.erb b/app/views/sessions/new.html.erb index bdec0de..ab95a24 100644 --- a/app/views/sessions/new.html.erb +++ b/app/views/sessions/new.html.erb @@ -1 +1 @@ -<%= link_to 'Sign in with Twitter', '/auth/twitter' %> +<%= link_to 'Sign in with GitHub', '/auth/github' %> diff --git a/config/initializers/omniauth.rb b/config/initializers/omniauth.rb index 05d79ed..90837ba 100644 --- a/config/initializers/omniauth.rb +++ b/config/initializers/omniauth.rb @@ -1,3 +1,3 @@ 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 diff --git a/config/routes.rb b/config/routes.rb index 269dce7..a55324a 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,62 +1,10 @@ MyImages::Application.routes.draw do - # The priority is based upon order of creation: first created -> highest priority. - # See how all your routes lay out with "rake routes". + root "home#index" - root 'home#index' - - resource :session, only: [:new, :destroy] - get '/auth/:provider/callback', to: 'sessions#create', as: :create_session + resource :session, only: %i[new destroy] + get "/auth/:provider/callback", to: "sessions#create", as: :create_session resource :user do resources :images 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