Created
March 26, 2011 21:27
-
-
Save Arcath/888650 to your computer and use it in GitHub Desktop.
LDAP Omniauth session code (post ldap improving)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def create | |
ldap_user = ActiveDirectoryUser.authenticate(params[:username], params[:password]) | |
user = User.find_by_provider_and_uid("ldap",params[:username]) || User.create_with_omniauth("ldap",params[:username]) | |
user.name = ldap_user.name | |
user.groups = ldap_user.groups.join(",") | |
user.save | |
if LDAP_AllowedGroups != (LDAP_AllowedGroups - user.groups.split(",")) then | |
session[:user_id] = user.id | |
redirect_to "/pages/splash" | |
else | |
redirect_to "/", :notice => "Succesful Login, but you don't have permission to use this application" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment