This repository
This repository
All repositories
Browse code

Fixed GitHub auth, GitHub can provide us with a valid email - so auto…

…matically log in for those cases
commit 803d023e2307309f8b776ab3b8b7e38ba91c0919 1 parent cf33326
authored
20  app/controllers/users/omniauth_callbacks_controller.rb
... ... @@ -210,6 +210,8 @@ def create_or_sign_on_user_using_openid(auth_token)
210 210  
211 211      if user_open_id.blank? && user = User.find_by_email(email)
212 212        # we trust so do an email lookup
  213 +      # TODO some openid providers may not be trust worthy, allow for that
  214 +      #  for now we are good (google, yahoo are trust worthy)
213 215        user_open_id = UserOpenId.create(url: identity_url , user_id: user.id, email: email, active: true)
214 216      end
215 217  
... ... @@ -250,18 +252,32 @@ def create_or_sign_on_user_using_github(auth_token)
250 252  
251 253      data = auth_token[:info]
252 254      screen_name = data["nickname"]
  255 +    email = data["email"]
253 256      github_user_id = auth_token["uid"]
254 257  
255 258      session[:authentication] = {
256 259        github_user_id: github_user_id,
257   -      github_screen_name: screen_name
  260 +      github_screen_name: screen_name,
  261 +      email: email,
  262 +      email_valid: true
258 263      }
259 264  
260 265      user_info = GithubUserInfo.where(github_user_id: github_user_id).first
261 266  
  267 +    if !user_info && user = User.find_by_email(email)
  268 +      # we trust so do an email lookup
  269 +      user_info = GithubUserInfo.create(
  270 +          user_id: user.id,
  271 +          screen_name: screen_name,
  272 +          github_user_id: github_user_id
  273 +      )
  274 +    end
  275 +
262 276      @data = {
263 277        username: screen_name,
264   -      auth_provider: "Github"
  278 +      auth_provider: "Github",
  279 +      email: email,
  280 +      email_valid: true
265 281      }
266 282  
267 283      process_user_info(user_info, screen_name)

0 notes on commit 803d023

Please sign in to comment.
Something went wrong with that request. Please try again.