我把这个放进去了
app/controllers/sessions_controller.rb
.
会话控制器.rb
class SessionsController < ApplicationController
# Authenticate user against their LDAP directory
# user and directory correspond to models in my app
# password is a string
# For complete source, see http://github.com/sidewaysmilk/auther
def directory_login(user, password)
directory = user.directory
return nil if !directory
directory.bind_dn['%s'] = user.login
ldap = Net::LDAP.new
ldap.host = directory.host
ldap.port = directory.port
ldap.encryption :simple_tls if directory.use_simple_tls?
ldap.auth directory.bind_dn, password
if ldap.bind
return user
end
end
end