forked from AdaGold/media-ranker-revisited
-
Notifications
You must be signed in to change notification settings - Fork 45
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
Kat -- MediaRanker-Revisited -- Octos #21
Open
kseastman
wants to merge
29
commits into
Ada-C9:master
Choose a base branch
from
kseastman:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
a71c4f6
added test for root.
kseastman ed3b3e9
added test for root.
kseastman 43f4319
completed first stub sections for root.
kseastman b43600c
completed stubbed tests for index.
kseastman 2b822c3
completed stubbed test for new.
kseastman 2388c3e
completed stubbed tests for create
kseastman e592765
completed stubbed tests for show.
kseastman 7fbbaf4
completed stubbed tests for show.
kseastman f2caf4c
stubbed tests for edit.
kseastman 41df54f
completed tests for update
kseastman 05b7015
added destroy test.
kseastman 60d0a5b
finished works controller tests
kseastman e050d51
added tests for users and sessions controller.
kseastman e91153f
add .env file
kseastman d7e3511
omniauth changes for github user auth.
kseastman 800f728
added user#build_from_github and controller logic.
kseastman d5b3bd3
forgot to add auth_hash variable, trying again.
kseastman 5b010f2
non-functional, commiting before drastic changes.
kseastman e05fd69
set login to /auth/github, login functional.
kseastman d35526d
stuff
kseastman 47d3843
Wave3: except - full unit testing around authentication using mocks
kseastman c46f74c
stashing before big changes.
kseastman e312aa1
dan's questing to find the location of the bug.
kseastman 729b808
changed |= logic in user.rb
kseastman 955ea48
more fiddling.
kseastman c53b86b
modified Gemfile and installed simplecov.
kseastman 4bae6da
never solved the csrf error, not done but finished.
kseastman 9a0a42d
Merge branch 'master' into ke/things-and-stuff
kseastman b18ff92
still can't resolve csrf issue.
kseastman 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,3 +15,7 @@ | |
|
||
# Ignore Byebug command history file. | ||
.byebug_history | ||
|
||
# Ignore OAUTH file | ||
.env | ||
/coverage |
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,34 +1,43 @@ | ||
class SessionsController < ApplicationController | ||
|
||
|
||
def login_form | ||
end | ||
|
||
def login | ||
username = params[:username] | ||
if username and user = User.find_by(username: username) | ||
auth_hash = request.env['omniauth.auth'] | ||
|
||
if auth_hash[:uid] | ||
user = User.find_by(uid: auth_hash[:uid], provider: 'github') | ||
if user.nil? | ||
# User doesn't match anything in the DB | ||
# Attempt to create a new user | ||
user = User.build_from_github(auth_hash) | ||
unless user.id | ||
raise | ||
end | ||
end | ||
|
||
# If we get here, we have the user instance | ||
session[:user_id] = user.id | ||
flash[:status] = :success | ||
flash[:result_text] = "Successfully logged in as existing user #{user.username}" | ||
flash[:result_text] = "Logged in successfully" | ||
redirect_to root_path | ||
else | ||
user = User.new(username: username) | ||
if user.save | ||
session[:user_id] = user.id | ||
flash[:status] = :success | ||
flash[:result_text] = "Successfully created new user #{user.username} with ID #{user.id}" | ||
else | ||
flash.now[:status] = :failure | ||
flash.now[:result_text] = "Could not log in" | ||
flash.now[:messages] = user.errors.messages | ||
render "login_form", status: :bad_request | ||
return | ||
end | ||
flash[:status] = :failure | ||
flash[:result_text] = "Could not log in" | ||
flash[:messages] = user.errors.messages | ||
redirect_to root_path | ||
end | ||
redirect_to root_path | ||
end | ||
|
||
|
||
|
||
def logout | ||
session[:user_id] = nil | ||
flash[:status] = :success | ||
flash[:result_text] = "Successfully logged out" | ||
redirect_to root_path | ||
end | ||
|
||
end |
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.
Hmm I don't think you want your production code to have a raise in it