Commit d5c2a3be5d16acf0641ab39dcd15033456d51fdf

Authored by Arthur Neves
1 parent 34ac342e
Exists in master and in 1 other branch production

Small refactoring

app/controllers/users/omniauth_callbacks_controller.rb
@@ -4,12 +4,12 @@ class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController @@ -4,12 +4,12 @@ class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
4 github_token = env["omniauth.auth"].credentials.token 4 github_token = env["omniauth.auth"].credentials.token
5 github_user = User.where(:github_login => github_login).first 5 github_user = User.where(:github_login => github_login).first
6 6
7 - if github_user.nil? && Errbit::Config.github_org_id 7 + if github_user.nil? && github_org_id = Errbit::Config.github_org_id
8 # See if they are a member of the organization that we have access for 8 # See if they are a member of the organization that we have access for
9 # If they are, automatically create an account 9 # If they are, automatically create an account
10 - client = client = Octokit::Client.new :access_token => github_token 10 + client = Octokit::Client.new(access_token: github_token)
11 org_ids = client.organizations.map { |org| org.id.to_s } 11 org_ids = client.organizations.map { |org| org.id.to_s }
12 - if org_ids.include? Errbit::Config.github_org_id 12 + if org_ids.include?(github_org_id)
13 github_user = User.create(name: env["omniauth.auth"].extra.raw_info.name, email: env["omniauth.auth"].extra.raw_info.email) 13 github_user = User.create(name: env["omniauth.auth"].extra.raw_info.name, email: env["omniauth.auth"].extra.raw_info.email)
14 end 14 end
15 end 15 end