lwqzx_auth 0.1.5 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4413efd6d9a77135f2eccab4196b6ed2edcd61ce1aae003821dc19aeebe72588
4
- data.tar.gz: f9c0c21a61e2b19314e4f3e6ecc1e39780c5dd32da24c40bdfbf7ed1920443ee
3
+ metadata.gz: 64272f39bbb1397e25389d8b596f1d66cb940dd350e4d32cddc3334567dda01a
4
+ data.tar.gz: c14332035bf008e1ed5c8a812e27590677bcff97887b0df36a24f820d8956103
5
5
  SHA512:
6
- metadata.gz: 7e4addf6407cbadfc2a342779f8507cf578c912f96b91e6946de90e05497b69647906fe1c04b7f846929a7afb259818b854e10f31654b5f6cc9de72782ff814b
7
- data.tar.gz: 6af0125425af9aa7bd72487ac08de3bc295f44a277f7c9f83d6a545eea3e9d700aaa5c6d2e95a02f95957709128b7745b7872cb6b4e02dea46b66a69c7d1d19b
6
+ metadata.gz: a842d49963961e790f055fe069db1805606e56d5b281193cbd5e1267b675163dc07871981c20f5a77064864ab72a450ee5e6a8ce654b7213c192265ef6181832
7
+ data.tar.gz: f0510454c1f24fcf8c0576aad604673d78de886ced7b4cbece782c09ee8be93f4fa63b877095909be0c276fb04a76249d93ff7a34609edcb20dc64b20de5b24b
@@ -12,9 +12,9 @@ module LwqzxAuth
12
12
  end
13
13
 
14
14
  def auth
15
- unless verify_rucaptcha?
15
+ unless verify_rucaptcha?
16
16
  flash[:alert] = "验证码出错"
17
- redirect_to main_app.root_path and return
17
+ redirect_to main_app.root_path and return
18
18
  end
19
19
 
20
20
  login = params[:login]
@@ -35,20 +35,16 @@ module LwqzxAuth
35
35
  private
36
36
  def lauth(login,passwd)
37
37
  lurl = "http://www.lwqzx.sdedu.net/kernel/net_school/active_app/login1.php"
38
- user = "login_user_m_=#{login}"
39
- psd = "login_password=#{passwd}"
40
- res = %x[curl #{lurl} -s -c /tmp/cookies -d #{user} -d #{psd} ]
41
- aurl = "http://www.lwqzx.sdedu.net/kernel/net_school/islogin.php"
42
- ares = %x[curl -s -b /tmp/cookies #{aurl}]
43
- return {} if ares.to_s == "0"
44
- infos = %x[curl -s -b /tmp/cookies #{lurl}]
45
- content=infos.encode("UTF-8","GB2312")
38
+ res1 = RestClient.post lurl,{login_user_m_: login, login_password: passwd}
39
+ res2 = RestClient.get lurl,{cookies: res1.cookies}
40
+ content=res2.body.encode("UTF-8","GB2312")
46
41
  doc = Nokogiri::HTML(content)
42
+ return {} if doc.include?("login_submit")
47
43
  uname = doc.css("span.tt1 a:nth-child(1)").text
48
44
  groups = doc.css("span.tt1 a:nth-child(5)")[0]["title"]
49
- %x[rm /tmp/cookies]
50
45
  groups=groups.gsub("[","").gsub("]","").split("@").compact.reject(&:empty?)
51
46
  return {login: login, name: uname, groups: groups}
52
- end
47
+ end
48
+
53
49
  end
54
50
  end
@@ -1,3 +1,3 @@
1
1
  module LwqzxAuth
2
- VERSION = '0.1.5'
2
+ VERSION = '0.1.6'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lwqzx_auth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - zxy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-10-14 00:00:00.000000000 Z
11
+ date: 2019-03-18 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: auth function into host app.
14
14
  email: