From d7378a350707a26850ac67c95a94b2d7906da9d3 Mon Sep 17 00:00:00 2001 From: "Chris Baudouin, Jr" Date: Fri, 19 Jun 2020 21:29:00 -0400 Subject: [PATCH 1/2] fix(login): Removes always visible login error --- app/controllers/application_controller.rb | 2 -- app/views/devise/sessions/new.html.haml | 4 ---- config/routes.rb | 12 ++++++++++-- test/integration/user_flows_test.rb | 2 +- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 0e3b50bdf..00bdf3bc4 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -5,8 +5,6 @@ def after_sign_in_path_for(resource) stored_location = stored_location_for(resource) if stored_location stored_location - elsif current_user.admin? || current_user.admin_limited_access? - manage_root_path elsif current_user.questionnaire.nil? new_questionnaires_path else diff --git a/app/views/devise/sessions/new.html.haml b/app/views/devise/sessions/new.html.haml index 15a762ec3..822d2b20f 100644 --- a/app/views/devise/sessions/new.html.haml +++ b/app/views/devise/sessions/new.html.haml @@ -3,8 +3,4 @@ %h1.section-title.center Sign in to %span.emphasized= HackathonConfig['name'] - - if notice - .form-success - .success_message - %p#notice= notice = render 'form' diff --git a/config/routes.rb b/config/routes.rb index 0cc0da386..ee194b136 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -4,12 +4,20 @@ require "sidekiq/web" require "sidekiq/cron/web" - devise_for :users, controllers: { registrations: "users/registrations", omniauth_callbacks: "users/omniauth_callbacks" } + devise_for :users, controllers: { registrations: "users/registrations", omniauth_callbacks: "users/omniauth_callbacks"} use_doorkeeper mount MailPreview => "mail_view" if Rails.env.development? - root to: "questionnaires#show" + devise_scope :user do + authenticated do + root to: "questionnaires#show" + end + + unauthenticated do + root to: "devise/sessions#new" + end + end authenticate :user, ->(u) { u.admin? } do mount Sidekiq::Web => "/sidekiq" diff --git a/test/integration/user_flows_test.rb b/test/integration/user_flows_test.rb index b7bdb9554..f6131b5cf 100644 --- a/test/integration/user_flows_test.rb +++ b/test/integration/user_flows_test.rb @@ -12,7 +12,7 @@ class UserFlowsTest < ActionDispatch::IntegrationTest should "be able to login and browse site as an admin" do login(FactoryBot.create(:admin)) - assert_redirected_to manage_root_path + assert_redirected_to new_questionnaires_path get manage_dashboard_index_path assert_response :success From afaba4ac4e3661e974cc943ab582807d90ad543a Mon Sep 17 00:00:00 2001 From: "Chris Baudouin, Jr" Date: Fri, 19 Jun 2020 23:32:59 -0400 Subject: [PATCH 2/2] Fixes Hound spacing requirement --- config/routes.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/routes.rb b/config/routes.rb index ee194b136..eb90c161d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -4,7 +4,7 @@ require "sidekiq/web" require "sidekiq/cron/web" - devise_for :users, controllers: { registrations: "users/registrations", omniauth_callbacks: "users/omniauth_callbacks"} + devise_for :users, controllers: { registrations: "users/registrations", omniauth_callbacks: "users/omniauth_callbacks" } use_doorkeeper mount MailPreview => "mail_view" if Rails.env.development?