LDAP done

This commit is contained in:
vsizov 2012-01-28 16:23:17 +03:00
parent d885f24f7b
commit d6a0b8f428
6 changed files with 37 additions and 24 deletions

View file

@ -66,6 +66,22 @@ class User < ActiveRecord::Base
def self.generate_random_password
(0...8).map{ ('a'..'z').to_a[rand(26)] }.join
end
def self.find_for_ldap_auth(omniauth)
username = omniauth.sAMAccountName[0]
email = omniauth.userprincipalname[0]
if @user = User.find_by_email(email)
@user
else
password = generate_random_password
@user = User.create(:name => username,
:email => email,
:password => password,
:password_confirmation => password
)
end
end
end
# == Schema Information
#