Chris Oliver 5 years ago
parent
commit
1bbaf0f25e
4 changed files with 7 additions and 9 deletions
  1. 1 1
      README.md
  2. 2 4
      app/models/service.rb
  3. 2 2
      app/views/shared/_navbar.html.erb
  4. 2 2
      template.rb

+ 1 - 1
README.md

@@ -39,7 +39,7 @@ EDITOR=vim rails credentials:edit
 
 Make sure your file follow this structure:
 
-```
+```yml
 secret_key_base: [your-key]
 development:
   github:

+ 2 - 4
app/models/service.rb

@@ -1,9 +1,7 @@
 class Service < ApplicationRecord
   belongs_to :user
 
-  PROVIDERS = %w{ facebook twitter github }
-
-  PROVIDERS.each do |provider|
+  Devise.omniauth_configs.keys.each do |provider|
     scope provider, ->{ where(provider: provider) }
   end
 
@@ -31,4 +29,4 @@ class Service < ApplicationRecord
   end
 
   def twitter_refresh_token!(token); end
-end
+end

+ 2 - 2
app/views/shared/_navbar.html.erb

@@ -28,10 +28,10 @@
          </li>
 
           <li class="nav-item dropdown">
-            <%= link_to root_path, id: "navbar-dropdown", class: "nav-link dropdown-toggle", data: { toggle: "dropdown" }, aria: { haspopup: true, expanded: false } do %>
+            <%= link_to "#", id: "navbar-dropdown", class: "nav-link dropdown-toggle", data: { target: "nav-account-dropdown", toggle: "dropdown" }, aria: { haspopup: true, expanded: false } do %>
               <%= image_tag gravatar_image_url(current_user.email, size: 40), height: 20, width: 20, class: "rounded" %>
             <% end %>
-            <div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbar-dropdown">
+            <div id="nav-account-dropdown" class="dropdown-menu dropdown-menu-right" aria-labelledby="navbar-dropdown">
               <% if current_user.admin? %>
                 <%= link_to "Admin Area", admin_root_path, class: "dropdown-item" %>
               <% end %>

+ 2 - 2
template.rb

@@ -185,9 +185,9 @@ def add_multiple_authentication
 
     template = """
     env_creds = Rails.application.credentials[Rails.env.to_sym] || {}
-    Service::PROVIDERS.each do |provider|
+    %w{ facebook twitter github }.each do |provider|
       if options = env_creds[provider]
-        confg.omniauth provider, options[:app_id], options[:app_secret], options.fetch(:options, {})
+        config.omniauth provider, options[:app_id], options[:app_secret], options.fetch(:options, {})
       end
     end
     """.strip