Commit df27ec29f3e0514ad80da95673b5b02e3fb10125

Authored by Dmitriy Zaporozhets
2 parents 2e83de19 a44b85be

Merge branch 'master' of dev.gitlabhq.com:gitlabhq

app/controllers/omniauth_callbacks_controller.rb
@@ -2,8 +2,8 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController @@ -2,8 +2,8 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController
2 2
3 def ldap 3 def ldap
4 # We only find ourselves here if the authentication to LDAP was successful. 4 # We only find ourselves here if the authentication to LDAP was successful.
5 - omniauth = request.env["omniauth.auth"]["extra"]["raw_info"]  
6 - @user = User.find_for_ldap_auth(omniauth) 5 + info = request.env["omniauth.auth"]["info"]
  6 + @user = User.find_for_ldap_auth(info)
7 if @user.persisted? 7 if @user.persisted?
8 @user.remember_me = true 8 @user.remember_me = true
9 end 9 end
app/models/user.rb
@@ -71,15 +71,15 @@ class User < ActiveRecord::Base @@ -71,15 +71,15 @@ class User < ActiveRecord::Base
71 name.split(" ").first unless name.blank? 71 name.split(" ").first unless name.blank?
72 end 72 end
73 73
74 - def self.find_for_ldap_auth(omniauth)  
75 - username = omniauth.sAMAccountName[0]  
76 - email = omniauth.userprincipalname[0] 74 + def self.find_for_ldap_auth(omniauth_info)
  75 + name = omniauth_info.name
  76 + email = omniauth_info.email
77 77
78 if @user = User.find_by_email(email) 78 if @user = User.find_by_email(email)
79 @user 79 @user
80 else 80 else
81 password = generate_random_password 81 password = generate_random_password
82 - @user = User.create(:name => username, 82 + @user = User.create(:name => name,
83 :email => email, 83 :email => email,
84 :password => password, 84 :password => password,
85 :password_confirmation => password 85 :password_confirmation => password