diff --git a/Gemfile b/Gemfile index dc28553d..a1ed5fb0 100644 --- a/Gemfile +++ b/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' diff --git a/Gemfile.lock b/Gemfile.lock index d5ae1680..5089191c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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) diff --git a/app/assets/javascripts/inc/search.js b/app/assets/javascripts/inc/search.js index 979b5621..70507fc6 100644 --- a/app/assets/javascripts/inc/search.js +++ b/app/assets/javascripts/inc/search.js @@ -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 - 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'); - }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(); - } + sval = $(this).val(); + $(".checkbox").popover("hide"); + $("div.checkblock").hide(); + clearInterval(interval); + interval = setInterval(waitForSearch,1000); }) -}) \ No newline at end of file +}) +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); +} \ No newline at end of file diff --git a/app/assets/stylesheets/new_admin.css.erb b/app/assets/stylesheets/new_admin.css.erb index 9d687eb6..d336a2de 100644 --- a/app/assets/stylesheets/new_admin.css.erb +++ b/app/assets/stylesheets/new_admin.css.erb @@ -8,8 +8,8 @@ *= require bootstrap *= require bootstrap-orbit *= require list - *= require widgets *= require style + *= widget *= require scroll_style *= require isotope -*/ \ No newline at end of file +*/ diff --git a/app/assets/stylesheets/widget.css b/app/assets/stylesheets/widget.css index 7a658f36..2a9f430d 100644 --- a/app/assets/stylesheets/widget.css +++ b/app/assets/stylesheets/widget.css @@ -145,4 +145,4 @@ position: absolute; visibility: hidden; left: 11px; -} \ No newline at end of file +} diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index 2c8b9707..a27f2841 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -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') diff --git a/app/views/devise/sessions/new.html.erb b/app/views/devise/sessions/new.html.erb index 78c94936..74c78d0b 100644 --- a/app/views/devise/sessions/new.html.erb +++ b/app/views/devise/sessions/new.html.erb @@ -1,8 +1,9 @@ -