-
Notifications
You must be signed in to change notification settings - Fork 1
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
[22 | 24] Users can login/logout via Rails app #101
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
20e41ff
22|24 Initial layout, user updates, login/logout
cpreisinger 2b8dff4
22|24 Rubocop autofixes
cpreisinger 9ac3061
22|24 Remaining Rubocop adjustments
cpreisinger d526987
Merge branch 'dev' of github.com:GSA/Challenge_platform into 22/user-…
cpreisinger f645e0e
22|24 Fix rubocop issues
cpreisinger 29608f6
22|24 Fix failing tests
cpreisinger 1715b88
22|24 Revert tool-versions system change
cpreisinger 006c02a
22|24 Add back development.rb
cpreisinger 830b635
Locked simplecov version for codeclimate error
cpreisinger 924e72d
22 PR feedback. Mil emails. Timestamp changes
cpreisinger d46abdb
22 Fix trailing whitespace errors
cpreisinger b68d881
22 Reverted structure.sql22 Reverted structure.sql
cpreisinger 39af8b4
Merge branch 'dev' of github.com:GSA/Challenge_platform into 22/user-…
cpreisinger File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,34 @@ | ||
# frozen_string_literal: true | ||
|
||
class ApplicationController < ActionController::Base | ||
helper_method :current_user, :logged_in? | ||
|
||
def current_user | ||
return unless session[:userinfo] | ||
|
||
user_token = session["userinfo"][0]["sub"] | ||
@current_user ||= User.find_by(token: user_token) if user_token | ||
end | ||
|
||
def logged_in? | ||
!!current_user | ||
end | ||
|
||
def sign_in(login_userinfo) | ||
user = User.user_from_userinfo(login_userinfo) | ||
|
||
@current_user = user | ||
session[:userinfo] = login_userinfo | ||
end | ||
|
||
def sign_out | ||
@current_user = nil | ||
session.delete(:userinfo) | ||
end | ||
|
||
def redirect_if_logged_in(path = "/dashboard") | ||
return unless logged_in? | ||
|
||
redirect_to path, notice: I18n.t("already_logged_in_notice") | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# frozen_string_literal: true | ||
|
||
class DashboardController < ApplicationController | ||
def index; end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<div class="usa-card__container custom-card col-md-6 rules-of-behavior"> | ||
<div class="usa-card__body"> | ||
<% if logged_in? %> | ||
Logged In Dashboard Index | ||
<% else %> | ||
Logged Out Dashboard Index | ||
<% end %> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<header class="usa-header usa-header--basic margin-bottom-2"> | ||
<div class="usa-nav-container"> | ||
<div class="usa-navbar"> | ||
<div class="usa-logo"> | ||
<em class="usa-logo__text"> | ||
<a href="/" title="Challenge Platform">Challenge Platform</a> | ||
</em> | ||
</div> | ||
</div> | ||
<nav aria-label="Primary navigation" class="usa-nav"> | ||
<% if logged_in? %> | ||
<%= button_to("Logout", session_path, method: :delete, class: "usa-button usa-nav-link", type: "button") %> | ||
<% else %> | ||
<%= button_to("Login", new_session_path, method: :get, class: "usa-button usa-nav-link", type: "button") %> | ||
<% end %> | ||
</nav> | ||
</div> | ||
</header> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ | |
</head> | ||
|
||
<body> | ||
<%= render "layouts/header" %> | ||
<%= yield %> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤘