Commit df27ec29 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

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

parents 2e83de19 a44b85be
......@@ -2,8 +2,8 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController
def ldap
# We only find ourselves here if the authentication to LDAP was successful.
omniauth = request.env["omniauth.auth"]["extra"]["raw_info"]
@user = User.find_for_ldap_auth(omniauth)
info = request.env["omniauth.auth"]["info"]
@user = User.find_for_ldap_auth(info)
if @user.persisted?
@user.remember_me = true
end
......
......@@ -71,15 +71,15 @@ class User < ActiveRecord::Base
name.split(" ").first unless name.blank?
end
def self.find_for_ldap_auth(omniauth)
username = omniauth.sAMAccountName[0]
email = omniauth.userprincipalname[0]
def self.find_for_ldap_auth(omniauth_info)
name = omniauth_info.name
email = omniauth_info.email
if @user = User.find_by_email(email)
@user
else
password = generate_random_password
@user = User.create(:name => username,
@user = User.create(:name => name,
:email => email,
:password => password,
:password_confirmation => password
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment