From 44df301aca6403038ca02711612e9e693b7be12c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B1=E5=8D=9A=E4=BA=9E?= Date: Mon, 24 Jan 2022 12:56:17 +0800 Subject: [PATCH] fix error --- lib/ldap_login/login.rb | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/ldap_login/login.rb b/lib/ldap_login/login.rb index f902a82..b686f65 100644 --- a/lib/ldap_login/login.rb +++ b/lib/ldap_login/login.rb @@ -8,13 +8,16 @@ module LdapLogin::Login login_flag = false url = '/' url_method = 'redirect_to' - + uri = URI(LDAP_ADSERVER) req = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json') req.body = {AppKey: AppKey,username: ldap_user,password: ldap_pass}.to_json - res = Net::HTTP.start(uri.hostname, uri.port) do |http| - http.request(req) - end + req.read_timeout = 3000 + + http = Net::HTTP.new(uri.host, uri.port) + http.use_ssl = true + http.verify_mode = OpenSSL::SSL::VERIFY_NONE + res = http.request(req) if res.code == '200' && JSON.load(res.body)["userID"]==ldap_user if !user.nil?