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 +4 -4
- data/app/assets/stylesheets/lwqzx_auth/application.scss +0 -1
- data/app/controllers/lwqzx_auth/application_controller.rb +2 -1
- data/app/controllers/lwqzx_auth/auth_controller.rb +21 -2
- data/lib/lwqzx_auth/version.rb +1 -1
- metadata +4 -7
- data/app/helpers/lwqzx_auth/auth_helper.rb +0 -4
- data/app/views/lwqzx_auth/auth/auth.html.slim +0 -2
- data/app/views/lwqzx_auth/auth/logout.html.slim +0 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 343a08eefd6093a3c5edaa02685a7431c203724b
|
4
|
+
data.tar.gz: dae05e6234bfcd6be868b72d7fcdc95aee20feb8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '08e19a5d9b9db982b235ec2c502ba792bf98683c82ddd8283911a7dfd5e20aea223cf482ce1316e4b19e3721e45953c3963503cafd38378c23eb8c68dfdbdf8c'
|
7
|
+
data.tar.gz: b63424f45b6051b1bf9fdde9fa4d6ab6909ce062b310c90c0786a8bd735bbd79c453ed2fe4904b8afe9ab8c421d6e47f412d4313b846582f8a638fb2c22b81a5
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require_dependency "lwqzx_auth/application_controller"
|
2
2
|
|
3
3
|
module LwqzxAuth
|
4
|
-
class AuthController <
|
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 =
|
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
|
data/lib/lwqzx_auth/version.rb
CHANGED
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.
|
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-
|
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:
|
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:
|
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
|