Merge branch 'master' of dev.gitlabhq.com:gitlabhq
This commit is contained in:
commit
df27ec29f3
2 changed files with 6 additions and 6 deletions
|
@ -2,8 +2,8 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController
|
||||||
|
|
||||||
def ldap
|
def ldap
|
||||||
# We only find ourselves here if the authentication to LDAP was successful.
|
# We only find ourselves here if the authentication to LDAP was successful.
|
||||||
omniauth = request.env["omniauth.auth"]["extra"]["raw_info"]
|
info = request.env["omniauth.auth"]["info"]
|
||||||
@user = User.find_for_ldap_auth(omniauth)
|
@user = User.find_for_ldap_auth(info)
|
||||||
if @user.persisted?
|
if @user.persisted?
|
||||||
@user.remember_me = true
|
@user.remember_me = true
|
||||||
end
|
end
|
||||||
|
|
|
@ -71,15 +71,15 @@ class User < ActiveRecord::Base
|
||||||
name.split(" ").first unless name.blank?
|
name.split(" ").first unless name.blank?
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.find_for_ldap_auth(omniauth)
|
def self.find_for_ldap_auth(omniauth_info)
|
||||||
username = omniauth.sAMAccountName[0]
|
name = omniauth_info.name
|
||||||
email = omniauth.userprincipalname[0]
|
email = omniauth_info.email
|
||||||
|
|
||||||
if @user = User.find_by_email(email)
|
if @user = User.find_by_email(email)
|
||||||
@user
|
@user
|
||||||
else
|
else
|
||||||
password = generate_random_password
|
password = generate_random_password
|
||||||
@user = User.create(:name => username,
|
@user = User.create(:name => name,
|
||||||
:email => email,
|
:email => email,
|
||||||
:password => password,
|
:password => password,
|
||||||
:password_confirmation => password
|
:password_confirmation => password
|
||||||
|
|
Loading…
Add table
Reference in a new issue