Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion app/controllers/api/base_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

class Api::BaseController < ApplicationController
before_action :transform_json_params
before_action :authenticate_user!

# Handle JSON parsing errors
rescue_from JSON::ParserError, with: :handle_json_parse_error
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# frozen_string_literal: true

class ApplicationController < ActionController::Base
before_action :authenticate_user!

rescue_from CanCan::AccessDenied do |exception|
if current_user.nil?
redirect_to new_user_session_path
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# frozen_string_literal: true

class S3BrowserAppController < ApplicationController
class UiController < ApplicationController
layout 's3_browser'
before_action :authenticate_user!
before_action :authorize_s3_browser_access!

def index; end
def home; end

private

Expand Down
2 changes: 1 addition & 1 deletion app/models/ability.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def initialize(user)
#
return if user.blank?

can ACCESS_S3_BROWSER_UI, S3BrowserAppController
can ACCESS_S3_BROWSER_UI, UiController

# We can add more Api Controllers and restrict access based on the current user
# Right now, any authenticated user can access any API
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const Notifications = () => {
const { notifications, dismissNotification } = useNotifications();

return (
<ToastContainer position="top-end" className="p-3">
<ToastContainer className="p-3 top-15 end-0">
{notifications.map((notification) => (
<Notification
key={notification.id}
Expand Down
19 changes: 15 additions & 4 deletions app/views/layouts/s3_browser.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,19 @@

<%= yield :head %>
</head>

<body id="main-content">
<%= yield %>
</body>
<body id="main-content">
<nav class="d-flex py-2 px-5 bg-primary bg-opacity-25 justify-content-end">
<% if user_signed_in? %>
<% # The sign out route uses a DELETE method to prevent CSRF attacks. %>
<p>
<%= form_with(url: destroy_user_session_path, method: "delete") do |form| %>
<%= form.submit "Sign out", class: "btn btn-light btn-sm" %>
<% end %>
</p>
<% else %>
<p><%= link_to 'Sign in', user_session_path %></p>
<% end %>
</nav>
<%= yield %>
</body>
</html>
File renamed without changes.
8 changes: 4 additions & 4 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
get '/users/development/sign_in_developer', to: 'users/development#sign_in_developer' if Rails.env.development?
end

get '/browse', to: 's3_browser_app#index'
get '/browse/*path', to: 's3_browser_app#index'

# S3 Browser API routes
namespace :api do
get '/buckets', to: 's3_browser#index_buckets', format: 'json'
Expand All @@ -35,5 +32,8 @@
get 'up' => 'rails/health#show', as: :rails_health_check

# Defines the root path route ("/")
root 'pages#home'
root 'ui#home'

# All other routes should be handled by the react application
get '*path', to: 'ui#home'
end
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

require 'rails_helper'

describe S3BrowserAppController, type: :request do
describe UiController, type: :request do
describe 'index' do
before do
get '/browse'
get '/'
end

context 'as unauthenticated user' do
Expand All @@ -23,7 +23,7 @@

before do
sign_in user
get '/browse'
get '/'
end

it 'responds with OK status' do
Expand Down
Loading