Commit a90d5ef

mo <mo@mokhan.ca>
2018-12-15 22:04:53
make sessions/show public
1 parent d3cb713
Changed files (5)
app/controllers/my/audits_controller.rb
@@ -3,7 +3,7 @@
 module My
   class AuditsController < ApplicationController
     def index
-      @audits = Audited::Audit.all
+      @audits = current_user.own_and_associated_audits
     end
   end
 end
app/controllers/sessions_controller.rb
@@ -10,7 +10,7 @@ class SessionsController < ApplicationController
     :Signature,
   ].freeze
   skip_before_action :verify_authenticity_token, only: [:new, :destroy]
-  skip_before_action :authenticate!, only: [:new, :create, :destroy]
+  skip_before_action :authenticate!, only: [:new, :show, :create, :destroy]
 
   def new
     binding = binding_for(
app/models/mfa.rb
@@ -8,7 +8,7 @@ class Mfa
   end
 
   def setup?
-    secret.present?
+    secret.present? && user.changes[:mfa_secret].nil?
   end
 
   def provisioning_uri
app/views/layouts/application.html.erb
@@ -9,9 +9,7 @@
     <%= stylesheet_pack_tag 'application' %>
   </head>
   <body>
-    <% if current_user? && mfa_completed? %>
-      <div class="container" data-controller="content-loader" data-content-loader-url="<%= session_path %>"></div>
-    <% end %>
+    <div class="container" data-controller="content-loader" data-content-loader-url="<%= session_path %>"></div>
     <%= render partial: 'flash' %>
     <%= yield %>
   </body>
app/views/sessions/show.html.erb
@@ -1,36 +1,38 @@
-<nav class="navbar" role="navigation" aria-label="main navigation">
-  <div class="navbar-brand">
-    <%= link_to my_dashboard_path, class: 'navbar-item' do %>
-      <img src="<%= asset_pack_path("images/logo.png") %>" height="28" />
-    <% end %>
-    <a role="button" class="navbar-burger burger" aria-label="menu" aria-expanded="false" data-target="navigation-bar">
-      <span aria-hidden="true"></span>
-      <span aria-hidden="true"></span>
-      <span aria-hidden="true"></span>
-    </a>
-  </div>
-  <div id='navigation-bar' class="navbar-menu">
-    <div class="navbar-start">
-      <%= link_to t(".home"), my_dashboard_path, class: 'navbar-item' %>
-      <%= link_to t(".documentation"), '/doc/', class: 'navbar-item' %>
-      <div class="navbar-item has-dropdown is-hoverable">
-        <a class="navbar-link"> <%= t('.more') %> </a>
-        <div class="navbar-dropdown">
-          <%= link_to t(".clients"), my_clients_path, class: 'navbar-item' %>
-          <%= link_to t(".mfa"), my_mfa_path, class: 'navbar-item' %>
-          <%= link_to t(".sessions"), my_sessions_path, class: 'navbar-item' %>
-          <%= link_to t(".audits"), my_audits_path, class: 'navbar-item' %>
-          <hr class="navbar-divider" />
-          <a class="navbar-item" href="https://github.com/saml-kit/proof/issues/new" target="_blank"><%= t('.report_an_issue') %></a>
+<% if current_user? && mfa_completed? %>
+  <nav class="navbar" role="navigation" aria-label="main navigation">
+    <div class="navbar-brand">
+      <%= link_to my_dashboard_path, class: 'navbar-item' do %>
+        <img src="<%= asset_pack_path("images/logo.png") %>" height="28" />
+      <% end %>
+      <a role="button" class="navbar-burger burger" aria-label="menu" aria-expanded="false" data-target="navigation-bar">
+        <span aria-hidden="true"></span>
+        <span aria-hidden="true"></span>
+        <span aria-hidden="true"></span>
+      </a>
+    </div>
+    <div id='navigation-bar' class="navbar-menu">
+      <div class="navbar-start">
+        <%= link_to t(".home"), my_dashboard_path, class: 'navbar-item' %>
+        <%= link_to t(".documentation"), '/doc/', class: 'navbar-item' %>
+        <div class="navbar-item has-dropdown is-hoverable">
+          <a class="navbar-link"> <%= t('.more') %> </a>
+          <div class="navbar-dropdown">
+            <%= link_to t(".clients"), my_clients_path, class: 'navbar-item' %>
+            <%= link_to t(".mfa"), my_mfa_path, class: 'navbar-item' %>
+            <%= link_to t(".sessions"), my_sessions_path, class: 'navbar-item' %>
+            <%= link_to t(".audits"), my_audits_path, class: 'navbar-item' %>
+            <hr class="navbar-divider" />
+            <a class="navbar-item" href="https://github.com/saml-kit/proof/issues/new" target="_blank"><%= t('.report_an_issue') %></a>
+          </div>
         </div>
       </div>
-    </div>
-    <div class="navbar-end">
-      <div class="navbar-item">
-        <div class="buttons">
-          <%= button_to t(".logout"), session_path, method: :delete, class: 'button is-danger' %>
+      <div class="navbar-end">
+        <div class="navbar-item">
+          <div class="buttons">
+            <%= button_to t(".logout"), session_path, method: :delete, class: 'button is-danger' %>
+          </div>
         </div>
       </div>
     </div>
-  </div>
-</nav>
+  </nav>
+<% end %>