NCCU ldap debug
This commit is contained in:
parent
7e355b77c2
commit
fe9032787c
1
Gemfile
1
Gemfile
|
@ -18,7 +18,6 @@ gem 'mini_magick'
|
|||
gem 'mongoid'
|
||||
gem "mongo_session_store-rails3"
|
||||
gem 'mysql2'
|
||||
gem "net-ldap", "~> 0.3.1"
|
||||
gem 'nokogiri'
|
||||
gem 'radius'
|
||||
gem 'rake'
|
||||
|
|
|
@ -116,9 +116,9 @@ GEM
|
|||
activemodel (~> 3.1)
|
||||
mongo (~> 1.3)
|
||||
tzinfo (~> 0.3.22)
|
||||
multi_json (1.1.0)
|
||||
mysql2 (0.3.11)
|
||||
net-ldap (0.3.1)
|
||||
multi_json (1.1.0)
|
||||
nokogiri (1.5.2)
|
||||
orm_adapter (0.0.6)
|
||||
pdf-writer (1.1.8)
|
||||
|
|
|
@ -8,24 +8,27 @@ $.extend($.expr[':'], {
|
|||
return (elem.textContent || elem.innerText || '').toLowerCase().indexOf((match[3] || "").toLowerCase()) >= 0;
|
||||
}
|
||||
});
|
||||
var interval,sval;
|
||||
$(document).ready(function(){
|
||||
$("#user_filter").keyup(function(){
|
||||
if($(this).val()){
|
||||
var totalfoundbyname = $("div#users_checkbox_ary label.member-name:containsi("+$(this).val()+")").length
|
||||
sval = $(this).val();
|
||||
$(".checkbox").popover("hide");
|
||||
$("div.checkblock").hide();
|
||||
clearInterval(interval);
|
||||
interval = setInterval(waitForSearch,1000);
|
||||
})
|
||||
})
|
||||
var waitForSearch = function(){
|
||||
if(sval){
|
||||
var totalfoundbyname = $("div#users_checkbox_ary label.member-name:containsi("+sval+")").length
|
||||
if(totalfoundbyname!=0){
|
||||
$("div#users_checkbox_ary label.member-name:not(:containsi("+$(this).val()+"))").parent().parent().slideUp();
|
||||
//$("div#users_checkbox_ary label.member-name:not(:containsi("+$(this).val()+"))").parent().popover('hide');
|
||||
$("div#users_checkbox_ary label.member-name:containsi("+$(this).val()+")").parent().parent().slideDown();
|
||||
$("div#users_checkbox_ary label.member-name:containsi("+$(this).val()+")").parent().popover('toggle');
|
||||
$("div#users_checkbox_ary label.member-name:containsi("+sval+")").parent().parent().show();
|
||||
}else if(totalfoundbyname==0){
|
||||
$("div#users_checkbox_ary div.for_unit:not(:containsi("+$(this).val()+"))").parent().slideUp();
|
||||
//$("div#users_checkbox_ary div.for_unit:not(:containsi("+$(this).val()+"))").popover('hide');
|
||||
$("div#users_checkbox_ary div.for_unit:containsi("+$(this).val()+")").parent().slideDown();
|
||||
$("div#users_checkbox_ary div.for_unit:containsi("+$(this).val()+")").popover('toggle');
|
||||
$("div#users_checkbox_ary div.for_unit:containsi("+sval+")").parent().show();
|
||||
}
|
||||
}else{
|
||||
$(".checkbox").popover('hide');
|
||||
$("div.checkblock").slideDown();
|
||||
$("div.checkblock").show();
|
||||
}
|
||||
clearInterval(interval);
|
||||
}
|
||||
})
|
||||
})
|
|
@ -8,8 +8,8 @@
|
|||
*= require bootstrap
|
||||
*= require bootstrap-orbit
|
||||
*= require list
|
||||
*= require widgets
|
||||
*= require style
|
||||
*= widget
|
||||
*= require scroll_style
|
||||
*= require isotope
|
||||
*/
|
|
@ -11,28 +11,28 @@ class SessionsController < Devise::SessionsController
|
|||
login_uid = params[:user][:nccu_ldap_uid]
|
||||
result = false
|
||||
ldap = Net::LDAP.new
|
||||
ldap.port = '8001'
|
||||
ldap.host = '127.0.0.1'
|
||||
# ldap.port = '389'
|
||||
# ldap.host = '140.119.166.23'
|
||||
#ldap.port = '8001'
|
||||
#ldap.host = '127.0.0.1'
|
||||
ldap.port = '389'
|
||||
ldap.host = '140.119.166.23'
|
||||
ldap_filter = "(uid=#{login_uid})"
|
||||
ldap_base = 'ou=People,dc=nccu,dc=edu,dc=tw'
|
||||
ldap.authenticate("cn=uccn,ou=profile,dc=nccu,dc=edu,dc=tw","nccu2ucc")
|
||||
if ldap.bind
|
||||
if ldap.bind && login_password!='' #need to block password empty
|
||||
result = ldap.bind_as(:base => ldap_base,:filter => ldap_filter,:password=> login_password)
|
||||
if result
|
||||
nccu_id = get_nccu_id_from_mid_site(login_uid)
|
||||
resource = User.first(conditions:{ nccu_id: nccu_id })
|
||||
resource = nccu_id.nil? ? nil : (User.first(conditions:{ nccu_id: nccu_id }))
|
||||
# resource = env['warden'].authenticate!(:check_nccu_ldap)
|
||||
# resource = warden.authenticate!(:scope => resource_name, :recall => "#{controller_path}#new")
|
||||
set_flash_message(:notice, :signed_in) if is_navigational_format?
|
||||
unless resource_name.nil?
|
||||
if (resource.nil? || nccu_id.nil?)
|
||||
flash[:notice] = t('devise.failure.ldap_pass_but_account_not_in_orbit')
|
||||
render :action => "new"
|
||||
else
|
||||
resource_name = resource._type.downcase
|
||||
sign_in(resource_name, resource)
|
||||
respond_with resource, :location => redirect_location(resource_name, resource)
|
||||
else
|
||||
flash[:notice] = t('devise.failure.ldap_pass_but_account_not_in_orbit')
|
||||
render :action => "new"
|
||||
end
|
||||
else
|
||||
flash[:notice] = t('devise.failure.ldap_invalid')
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
|
||||
<h1 class="login-logo"><%= t(:ruling_site) %></h1>
|
||||
<div id="signin-header">
|
||||
<h3><%= t(:login) %></h3>
|
||||
</div>
|
||||
|
||||
<%= flash_messages %>
|
||||
<div id="container" class="sign-in">
|
||||
<%= form_for :user, :url => user_session_path, :html => {:class => 'user_new form-horizontal'} do |f| %>
|
||||
<div class="content">
|
||||
|
|
|
@ -6,6 +6,8 @@ namespace :mid_site do
|
|||
officer_posgrp_code = %w{02 06 10 05} #from RSS2
|
||||
admin_role = nil
|
||||
sub_role = nil
|
||||
test_account_ldap_id ='139716'
|
||||
|
||||
|
||||
task :sync => :environment do
|
||||
info_profile = Info.first(conditions: {:key => 'profile'})
|
||||
|
@ -31,7 +33,7 @@ namespace :mid_site do
|
|||
#remove delete user sho has been deleted at remote first
|
||||
local_need_remove = User.all.collect{|t| t.nccu_id rescue nil}.uniq.delete_if {|x| x == nil} - remote_list
|
||||
desc "Going to delete User with IDs: #{local_need_remove.inspect}"
|
||||
local_need_remove.each{|user_id| (User.find user_id).destroy}
|
||||
local_need_remove = User.excludes(nccu_id: test_account_ldap_id ).collect{|t| t.nccu_id rescue nil}.uniq.delete_if {|x| x == nil} - remote_list
|
||||
desc "Deletion completed! \n"
|
||||
|
||||
#starting update user
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
<% sys_users.each do |user| -%>
|
||||
|
||||
<div class="checkblock">
|
||||
|
||||
<% user.sub_roles.each do |sr| %>
|
||||
<div class="for_unit" style="display:none;"> <%= sr.key %></div>
|
||||
<% end %>
|
||||
|
|
Loading…
Reference in New Issue