Merge commit 'b6f64cd8a5b48ad84703e3824ef4d968ed71779d' into ldap

This commit is contained in:
Matthew K. Fu JuYuan 2012-04-23 13:58:56 +08:00
commit 868118116b
10 changed files with 49 additions and 45 deletions

View File

@ -18,7 +18,6 @@ gem 'mini_magick'
gem 'mongoid' gem 'mongoid'
gem "mongo_session_store-rails3" gem "mongo_session_store-rails3"
gem 'mysql2' gem 'mysql2'
gem "net-ldap", "~> 0.3.1"
gem 'nokogiri' gem 'nokogiri'
gem 'radius' gem 'radius'
gem 'rake' gem 'rake'

View File

@ -116,9 +116,9 @@ GEM
activemodel (~> 3.1) activemodel (~> 3.1)
mongo (~> 1.3) mongo (~> 1.3)
tzinfo (~> 0.3.22) tzinfo (~> 0.3.22)
multi_json (1.1.0)
mysql2 (0.3.11) mysql2 (0.3.11)
net-ldap (0.3.1) net-ldap (0.3.1)
multi_json (1.1.0)
nokogiri (1.5.2) nokogiri (1.5.2)
orm_adapter (0.0.6) orm_adapter (0.0.6)
pdf-writer (1.1.8) pdf-writer (1.1.8)

View File

@ -8,24 +8,27 @@ $.extend($.expr[':'], {
return (elem.textContent || elem.innerText || '').toLowerCase().indexOf((match[3] || "").toLowerCase()) >= 0; return (elem.textContent || elem.innerText || '').toLowerCase().indexOf((match[3] || "").toLowerCase()) >= 0;
} }
}); });
var interval,sval;
$(document).ready(function(){ $(document).ready(function(){
$("#user_filter").keyup(function(){ $("#user_filter").keyup(function(){
if($(this).val()){ sval = $(this).val();
var totalfoundbyname = $("div#users_checkbox_ary label.member-name:containsi("+$(this).val()+")").length $(".checkbox").popover("hide");
if(totalfoundbyname!=0){ $("div.checkblock").hide();
$("div#users_checkbox_ary label.member-name:not(:containsi("+$(this).val()+"))").parent().parent().slideUp(); clearInterval(interval);
//$("div#users_checkbox_ary label.member-name:not(:containsi("+$(this).val()+"))").parent().popover('hide'); interval = setInterval(waitForSearch,1000);
$("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');
}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');
}
}else{
$(".checkbox").popover('hide');
$("div.checkblock").slideDown();
}
}) })
}) })
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:containsi("+sval+")").parent().parent().show();
}else if(totalfoundbyname==0){
$("div#users_checkbox_ary div.for_unit:containsi("+sval+")").parent().show();
}
}else{
$(".checkbox").popover('hide');
$("div.checkblock").show();
}
clearInterval(interval);
}

View File

@ -8,8 +8,8 @@
*= require bootstrap *= require bootstrap
*= require bootstrap-orbit *= require bootstrap-orbit
*= require list *= require list
*= require widgets
*= require style *= require style
*= widget
*= require scroll_style *= require scroll_style
*= require isotope *= require isotope
*/ */

View File

@ -11,28 +11,28 @@ class SessionsController < Devise::SessionsController
login_uid = params[:user][:nccu_ldap_uid] login_uid = params[:user][:nccu_ldap_uid]
result = false result = false
ldap = Net::LDAP.new ldap = Net::LDAP.new
ldap.port = '8001' #ldap.port = '8001'
ldap.host = '127.0.0.1' #ldap.host = '127.0.0.1'
# ldap.port = '389' ldap.port = '389'
# ldap.host = '140.119.166.23' ldap.host = '140.119.166.23'
ldap_filter = "(uid=#{login_uid})" ldap_filter = "(uid=#{login_uid})"
ldap_base = 'ou=People,dc=nccu,dc=edu,dc=tw' ldap_base = 'ou=People,dc=nccu,dc=edu,dc=tw'
ldap.authenticate("cn=uccn,ou=profile,dc=nccu,dc=edu,dc=tw","nccu2ucc") 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) result = ldap.bind_as(:base => ldap_base,:filter => ldap_filter,:password=> login_password)
if result if result
nccu_id = get_nccu_id_from_mid_site(login_uid) 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 = env['warden'].authenticate!(:check_nccu_ldap)
# resource = warden.authenticate!(:scope => resource_name, :recall => "#{controller_path}#new") # resource = warden.authenticate!(:scope => resource_name, :recall => "#{controller_path}#new")
set_flash_message(:notice, :signed_in) if is_navigational_format? 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 resource_name = resource._type.downcase
sign_in(resource_name, resource) sign_in(resource_name, resource)
respond_with resource, :location => redirect_location(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 end
else else
flash[:notice] = t('devise.failure.ldap_invalid') flash[:notice] = t('devise.failure.ldap_invalid')

View File

@ -1,8 +1,9 @@
<h1 class="login-logo"><%= t(:ruling_site) %></h1> <h1 class="login-logo"><%= t(:ruling_site) %></h1>
<div id="signin-header"> <div id="signin-header">
<h3><%= t(:login) %></h3> <h3><%= t(:login) %></h3>
</div> </div>
<%= flash_messages %>
<div id="container" class="sign-in"> <div id="container" class="sign-in">
<%= form_for :user, :url => user_session_path, :html => {:class => 'user_new form-horizontal'} do |f| %> <%= form_for :user, :url => user_session_path, :html => {:class => 'user_new form-horizontal'} do |f| %>
<div class="content"> <div class="content">

View File

@ -5,10 +5,10 @@
<%= content_tag :li, :class => active_for_controllers('bulletins', 'tags', 'bulletin_categorys', 'fact_checks') do -%> <%= content_tag :li, :class => active_for_controllers('bulletins', 'tags', 'bulletin_categorys', 'fact_checks') do -%>
<%= link_to content_tag(:i, nil, :class => 'icons-announcement') + t('admin.announcement'), panel_announcement_back_end_bulletins_path %> <%= link_to content_tag(:i, nil, :class => 'icons-announcement') + t('admin.announcement'), panel_announcement_back_end_bulletins_path %>
<%= content_tag :ul, :class => ("nav nav-list " + visible_for_controllers('bulletins', 'tags', 'bulletin_categorys', 'fact_checks')) do -%> <%= content_tag :ul, :class => ("nav nav-list " + visible_for_controllers('bulletins', 'tags', 'bulletin_categorys', 'fact_checks')) do -%>
<%= content_tag :li, link_to(t('admin.all_articles'), panel_announcement_back_end_bulletins_path), :class => active_for_action('bulletins', 'index') %> <%= content_tag :li, link_to(t('announcement.all_articles'), panel_announcement_back_end_bulletins_path), :class => active_for_action('bulletins', 'index') %>
<%= content_tag :li, link_to(t('admin.add_new'), new_panel_announcement_back_end_bulletin_path), :class => active_for_action('bulletins', 'new') %> <%= content_tag :li, link_to(t('announcement.add_new'), new_panel_announcement_back_end_bulletin_path), :class => active_for_action('bulletins', 'new') %>
<%= content_tag :li, link_to(t('admin.categories'), panel_announcement_back_end_bulletin_categorys_path), :class => active_for_action('bulletin_categorys', 'index') %> <%= content_tag :li, link_to(t('announcement.categories'), panel_announcement_back_end_bulletin_categorys_path), :class => active_for_action('bulletin_categorys', 'index') %>
<%= content_tag :li, link_to(t('admin.tags'), panel_announcement_back_end_tags_path), :class => active_for_action('panel/bulletin/back_end/tags', 'index') %> <%= content_tag :li, link_to(t('announcement.tags'), panel_announcement_back_end_tags_path), :class => active_for_action('panel/bulletin/back_end/tags', 'index') %>
<%= content_tag :li, link_to(t('announcement.bulletin.fact_check_setting'), panel_announcement_back_end_fact_checks_setting_path), :class => active_for_action('fact_checks', 'setting') if (is_manager? rescue nil) %> <%= content_tag :li, link_to(t('announcement.bulletin.fact_check_setting'), panel_announcement_back_end_fact_checks_setting_path), :class => active_for_action('fact_checks', 'setting') if (is_manager? rescue nil) %>
<% end -%> <% end -%>
@ -41,10 +41,10 @@
<%= content_tag :li, :class => active_for_controllers('web_links', 'tags', 'web_link_categorys') do -%> <%= content_tag :li, :class => active_for_controllers('web_links', 'tags', 'web_link_categorys') do -%>
<%= link_to content_tag(:i, nil, :class => 'icons-link') + t('admin.link'), panel_web_resource_back_end_web_links_path %> <%= link_to content_tag(:i, nil, :class => 'icons-link') + t('admin.link'), panel_web_resource_back_end_web_links_path %>
<%= content_tag :ul, :class => ("nav nav-list " + visible_for_controllers('web_links', 'tags', 'web_link_categorys')) do -%> <%= content_tag :ul, :class => ("nav nav-list " + visible_for_controllers('web_links', 'tags', 'web_link_categorys')) do -%>
<%= content_tag :li, link_to(t('admin.all_articles'), panel_web_resource_back_end_web_links_path), :class => active_for_action('web_link', 'index') %> <%= content_tag :li, link_to(t('admin.announcement.all_articles'), panel_web_resource_back_end_web_links_path), :class => active_for_action('web_link', 'index') %>
<%= content_tag :li, link_to(t('admin.add_new'), new_panel_web_resource_back_end_web_link_path), :class => active_for_action('web_link', 'new') %> <%= content_tag :li, link_to(t('admin.announcement.add_new'), new_panel_web_resource_back_end_web_link_path), :class => active_for_action('web_link', 'new') %>
<%= content_tag :li, link_to(t('admin.categories'), panel_web_resource_back_end_web_link_categorys_path), :class => active_for_action('web_link_categorys', 'index') %> <%= content_tag :li, link_to(t('admin.announcement.categories'), panel_web_resource_back_end_web_link_categorys_path), :class => active_for_action('web_link_categorys', 'index') %>
<%= content_tag :li, link_to(t('admin.tags'), panel_web_resource_back_end_tags_path), :class => active_for_action('panel/web_resource/back_end/tags', 'index') %> <%= content_tag :li, link_to(t('admin.announcement.tags'), panel_web_resource_back_end_tags_path), :class => active_for_action('panel/web_resource/back_end/tags', 'index') %>
<% end -%> <% end -%>
<% end -%> <% end -%>

View File

@ -6,6 +6,8 @@ namespace :mid_site do
officer_posgrp_code = %w{02 06 10 05} #from RSS2 officer_posgrp_code = %w{02 06 10 05} #from RSS2
admin_role = nil admin_role = nil
sub_role = nil sub_role = nil
test_account_ldap_id ='139716'
task :sync => :environment do task :sync => :environment do
info_profile = Info.first(conditions: {:key => 'profile'}) 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 #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 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}" 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" desc "Deletion completed! \n"
#starting update user #starting update user

View File

@ -3,7 +3,6 @@
<% sys_users.each do |user| -%> <% sys_users.each do |user| -%>
<div class="checkblock"> <div class="checkblock">
<% user.sub_roles.each do |sr| %> <% user.sub_roles.each do |sr| %>
<div class="for_unit" style="display:none;"> <%= sr.key %></div> <div class="for_unit" style="display:none;"> <%= sr.key %></div>
<% end %> <% end %>