lwqzx_auth 0.0.1 → 0.0.3

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
  SHA1:
3
- metadata.gz: c89c3369d7214b42bcea9a1d00dc88be52bfad83
4
- data.tar.gz: 59775c81b1d3f35f9cd0e0de5a976b622e594632
3
+ metadata.gz: 343a08eefd6093a3c5edaa02685a7431c203724b
4
+ data.tar.gz: dae05e6234bfcd6be868b72d7fcdc95aee20feb8
5
5
  SHA512:
6
- metadata.gz: d5a86dd5ab9df1725b461163e5161ca7287f494c25ad21fde9dcbcd89dca18d4f194c3dca6a2afc001dc3208960cc04ccce24b17f9253d90c0c2b817ba7d30de
7
- data.tar.gz: 918609846c5c89aeca3a3bbba9a7601b5ad16d4447b213abfaa57c0e490b587bf283f85c9d1d57c7a94d014e9e8d833895af8a3e0a0e77d7fb31ad18f3bca908
6
+ metadata.gz: '08e19a5d9b9db982b235ec2c502ba792bf98683c82ddd8283911a7dfd5e20aea223cf482ce1316e4b19e3721e45953c3963503cafd38378c23eb8c68dfdbdf8c'
7
+ data.tar.gz: b63424f45b6051b1bf9fdde9fa4d6ab6909ce062b310c90c0786a8bd735bbd79c453ed2fe4904b8afe9ab8c421d6e47f412d4313b846582f8a638fb2c22b81a5
@@ -3,4 +3,3 @@
3
3
  *= require_self
4
4
  */
5
5
  @import "bootstrap-sprockets";
6
- @import "bootstrap";
@@ -1,5 +1,6 @@
1
1
  module LwqzxAuth
2
- class ApplicationController < ActionController::Base
2
+ class ApplicationController < ::ApplicationController
3
3
  protect_from_forgery with: :exception
4
+
4
5
  end
5
6
  end
@@ -1,7 +1,7 @@
1
1
  require_dependency "lwqzx_auth/application_controller"
2
2
 
3
3
  module LwqzxAuth
4
- class AuthController < ::ApplicationController
4
+ class AuthController < ApplicationController
5
5
  def login
6
6
  end
7
7
 
@@ -14,7 +14,7 @@ module LwqzxAuth
14
14
  def auth
15
15
  login = params[:login]
16
16
  psd = params[:password]
17
- hsh = Lwqzx.auth(login,psd)
17
+ hsh = lauth(login,psd)
18
18
  if hsh.blank?
19
19
  redirect_to login_path , alert: "用户信息有误"
20
20
  else
@@ -26,5 +26,24 @@ module LwqzxAuth
26
26
  redirect_to main_app.root_path and return
27
27
  end
28
28
  end
29
+
30
+ private
31
+ def lauth(login,passwd)
32
+ lurl = "http://www.lwqzx.sdedu.net/kernel/net_school/active_app/login1.php"
33
+ user = "login_user_m_=#{login}"
34
+ psd = "login_password=#{passwd}"
35
+ res = %x[curl #{lurl} -s -c /tmp/cookies -d #{user} -d #{psd} ]
36
+ aurl = "http://www.lwqzx.sdedu.net/kernel/net_school/islogin.php"
37
+ ares = %x[curl -s -b /tmp/cookies #{aurl}]
38
+ return {} if ares.to_s == "0"
39
+ infos = %x[curl -s -b /tmp/cookies #{lurl}]
40
+ content=infos.encode("UTF-8","GB2312")
41
+ doc = Nokogiri::HTML(content)
42
+ uname = doc.css("span.tt1 a:nth-child(1)").text
43
+ groups = doc.css("span.tt1 a:nth-child(5)")[0]["title"]
44
+ %x[rm /tmp/cookies]
45
+ groups=groups.gsub("[","").gsub("]","").split("@").compact.reject(&:empty?)
46
+ return {login: login, name: uname, groups: groups}
47
+ end
29
48
  end
30
49
  end
@@ -1,3 +1,3 @@
1
1
  module LwqzxAuth
2
- VERSION = '0.0.1'
2
+ VERSION = '0.0.3'
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.0.1
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - zxy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-26 00:00:00.000000000 Z
11
+ date: 2017-04-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -39,7 +39,7 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: lwqzx
42
+ name: nokogiri
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
@@ -67,7 +67,7 @@ dependencies:
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
- name: slim-rails
70
+ name: nokogiri
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - ">="
@@ -96,13 +96,10 @@ files:
96
96
  - app/controllers/lwqzx_auth/application_controller.rb
97
97
  - app/controllers/lwqzx_auth/auth_controller.rb
98
98
  - app/helpers/lwqzx_auth/application_helper.rb
99
- - app/helpers/lwqzx_auth/auth_helper.rb
100
99
  - app/jobs/lwqzx_auth/application_job.rb
101
100
  - app/mailers/lwqzx_auth/application_mailer.rb
102
101
  - app/models/lwqzx_auth/application_record.rb
103
- - app/views/lwqzx_auth/auth/auth.html.slim
104
102
  - app/views/lwqzx_auth/auth/login.html.slim
105
- - app/views/lwqzx_auth/auth/logout.html.slim
106
103
  - config/routes.rb
107
104
  - lib/lwqzx_auth.rb
108
105
  - lib/lwqzx_auth/engine.rb
@@ -1,4 +0,0 @@
1
- module LwqzxAuth
2
- module AuthHelper
3
- end
4
- end
@@ -1,2 +0,0 @@
1
- h1 Auth#auth
2
- p Find me in app/views/auth/auth.html.slim
@@ -1,2 +0,0 @@
1
- h1 Auth#logout
2
- p Find me in app/views/auth/logout.html.slim