Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(login): Removes always visible login error #263

Merged
merged 5 commits into from
Jun 30, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 0 additions & 2 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions app/views/devise/sessions/new.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
12 changes: 10 additions & 2 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"}
cbaudouinjr marked this conversation as resolved.
Show resolved Hide resolved
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"
Expand Down
2 changes: 1 addition & 1 deletion test/integration/user_flows_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down