Skip to content

Commit

Permalink
Merge 5f054af into e6d72ea
Browse files Browse the repository at this point in the history
  • Loading branch information
pyro2927 committed Feb 2, 2014
2 parents e6d72ea + 5f054af commit b2ae349
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
10 changes: 10 additions & 0 deletions app/controllers/users/omniauth_callbacks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@ def github
github_token = env["omniauth.auth"].credentials.token
github_user = User.where(:github_login => github_login).first

if github_user.nil? && Errbit::Config.github_org_id
# See if they are a member of the organization that we have access for
# If they are, automatically create an account
client = client = Octokit::Client.new :access_token => github_token
org_ids = client.organizations.map { |org| org.id.to_s }
if org_ids.include? Errbit::Config.github_org_id
github_user = User.create(name: env["omniauth.auth"].extra.raw_info.name, email: env["omniauth.auth"].extra.raw_info.email)
end
end

# If user is already signed in, link github details to their account
if current_user
# ... unless a user is already registered with same github login
Expand Down
1 change: 1 addition & 0 deletions config/initializers/_load_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
Errbit::Config.github_authentication = ENV['GITHUB_AUTHENTICATION']
Errbit::Config.github_client_id = ENV['GITHUB_CLIENT_ID']
Errbit::Config.github_secret = ENV['GITHUB_SECRET']
Errbit::Config.github_org_id = ENV['GITHUB_ORG_ID'] if ENV['GITHUB_ORG_ID']
Errbit::Config.github_access_scope = ENV['GITHUB_ACCESS_SCOPE'].split(',').map(&:strip) if ENV['GITHUB_ACCESS_SCOPE']

Errbit::Config.smtp_settings = {
Expand Down

0 comments on commit b2ae349

Please sign in to comment.