Skip to content

Commit

Permalink
this address issue 18F#170
Browse files Browse the repository at this point in the history
* allows a local developer to log-in;
* bypasses oauth
* see .sample.env
* set developer email
* set skip_team_check to 'true'
  • Loading branch information
ChrisCPO committed Aug 28, 2016
1 parent a2f6a0f commit 7490e81
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .sample.env
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ EXECJS_RUNTIME=Node
GITHUB_CLIENT_ID=consumer_public_key
GITHUB_CLIENT_SECRET=consumer_secret_key
GITHUB_TEAM_ID=yourteamid
SKIP_TEAM_CHECK=false
DEVELOPER_EMAIL=[email protected]
30 changes: 25 additions & 5 deletions app/controllers/auth_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,36 @@ class AuthController < ApplicationController
skip_before_action :authenticate_user!, only: [:oauth_callback]

def oauth_callback
if team_member?
user = User.find_or_create_by(email: auth_email)
sign_in(user)
flash[:success] = "You successfully signed in"
redirect_to root_path
if ok_to_bypass_authentication?
create_user(developer_email)
else
if team_member?
create_user(auth_email)
end
end
end

private

def create_user(email)
user = User.find_or_create_by(email: email)
sign_in(user)
flash[:success] = "You successfully signed in"
redirect_to root_path
end

def ok_to_bypass_authentication?
Rails.env == "development" && skip_team_check?
end

def skip_team_check?
ENV["SKIP_TEAM_CHECK"].downcase == "true"
end

def developer_email
ENV["DEVELOPER_EMAIL"]
end

def team_member?
auth_hash.credentials.team_member?
end
Expand Down

0 comments on commit 7490e81

Please sign in to comment.