Commit 7fb1e5ea authored by Ryan Lee's avatar Ryan Lee

cleaned up functionality, appropriate permissions, tested for functionality

parent 8bdf09b3
class ZepheiraController < ApplicationController
skip_before_filter :verify_authenticity_token
def ldap
if request.post?
user = nil
created = false
login = params[:username]
auth_sources = AuthSource.find(:all)
auth_sources.each do |src|
if src.auth_method_name == 'LDAP'
user_dn = src.get_user_dn(login)
if user_dn.length > 0
attrs = src.get_user_attributes_from_ldap_entry(user_dn)
# Cheating. Private method.
attrs = src.__send__(:get_user_dn, login)
if attrs.length > 0
user = User.new(attrs.except([:dn, :login]))
user.login = login
user.language = Setting.default_language
if user.save
created = true
logger.info("User '#{user.login}' created from #{user.auth_source.name} by API") if logger && user.auth_source
end
end
end
end
if user.nil?
render_404
if !created
if user.nil?
render_404
else
render :nothing => true, :status => 422
end
else
render :nothing => true, :status => 201
end
else
render_405
render :nothing => true :status => 405
end
end
......
......@@ -10,7 +10,7 @@ module OpenProject::CreateLdapAccount
:author_url => 'http://zepheira.com/',
:requires_openproject => '>= 3.0.0' do
Redmine::AccessControl.permission(:create_ldap_account, { :controller => "zepheira", :action => "ldap" }, { :public => true })
Redmine::AccessControl.permission({:name => :create_ldap_account, :controller => "zepheira", :action => "ldap", :public => true })
end
end
end
module OpenProject
module CreateLdapAccount
VERSION = "1.0.0"
VERSION = "3.0.8"
end
end
# -*- encoding: utf-8 -*-
# stub: openproject-create_ldap_account 1.0.0 ruby lib
# stub: openproject-create_ldap_account 3.0.8 ruby lib
Gem::Specification.new do |s|
s.name = "openproject-create_ldap_account"
......@@ -15,7 +15,7 @@ Gem::Specification.new do |s|
s.files = ["README.md", "lib/openproject-create_ldap_account.rb", "lib/open_project/create_ldap_account.rb", "lib/open_project/create_ldap_account/engine.rb", "app/controllers/zepheira_controller.rb"]
s.homepage = "http://zepheira.com"
s.licenses = ["BSD"]
s.rubygems_version = "2.2.2"
s.rubygems_version = "2.4.3"
s.summary = "OpenProject LDAP Account Creation"
s.test_files = []
......
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