Skip to content

Commit

Permalink
Added redirection of users without profile to profile creation (#74)
Browse files Browse the repository at this point in the history
* Fixed logout routing

* Added redirection to profile creation when user profile is not found for user id
  • Loading branch information
Andres-L-Santiago authored Apr 10, 2024
1 parent a1030ea commit d0a783f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 2 additions & 0 deletions rails_root/app/controllers/home_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ class HomeController < ApplicationController
def index
return if session[:userinfo].nil?

redirect_to new_survey_profile_path if SurveyProfile.find_by(user_id: session[:userinfo]['sub']).nil?

@survey_profile = SurveyProfile.find_by(user_id: session[:userinfo]['sub'])
return if @survey_profile.nil?

Expand Down
8 changes: 4 additions & 4 deletions rails_root/app/views/layouts/_header.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@
<%= link_to "About", about_path, class: "nav-link #{'active' if current_page?(about_path)}" %>
</li>
<li class="nav-item">
<%# <%= link_to "Survey Responses", survey_responses_path, class: "nav-link #{'active' if current_page?(survey_responses_path)}" %>
<%# <%= link_to "Survey Responses", survey_responses_path, class: "nav-link #{'active' if current_page?(survey_responses_path)}" %>
</li>
<li class="nav-item">
<%# <%= link_to "Survey Profiles", survey_profiles_path, class: "nav-link #{'active' if current_page?(survey_profiles_path)}" %>
<%# <%= link_to "Survey Profiles", survey_profiles_path, class: "nav-link #{'active' if current_page?(survey_profiles_path)}" %>
</li>
<li class="nav-item">
<% if session[:userinfo] %>
<%= button_to 'Logout', 'auth/logout', method: :get, data: { turbo: false }, class: "nav-link" %>
<%= button_to 'Logout', root_url + '/auth/logout', method: :get, data: { turbo: false }, class: "nav-link" %>
<% else %>
<%= button_to 'Login', '/auth/auth0', method: :post, data: { turbo: false }, class: "nav-link" %>
<%= button_to 'Login', '/auth/auth0', method: :post, data: { turbo: false }, class: "nav-link" %>
<% end %>
</li>
</ul>
Expand Down
2 changes: 1 addition & 1 deletion rails_root/features/data_submission.feature
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Background: Questions and responses exist
Given I have logged in with user "1"
And I have no survey profile
When I visit new survey page
Then I should be on root page
Then I am redirected to the create survey profile page

Scenario: See Next button
Given I have logged in with user "1"
Expand Down

0 comments on commit d0a783f

Please sign in to comment.