lwqzx_auth 0.2.0 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b8c9ac0050837dc3ba05208b6cf877256463594c799cf4b137670145dedc574f
|
4
|
+
data.tar.gz: ec8eddbbdddf5b3e47c56ae84dfa96631775be444fafbdb0188b0ce764e61d80
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3518aff0e40db0abf15db0eb3118eb732ad0649c984adcb8bdbc3157c4070db343a1ac76869612e7a1d21ca336e379ad03e6d63c819fa1656768b38f4673a087
|
7
|
+
data.tar.gz: '08cbd3dc914637acf9d81e091f1154596ab2323fe4a4a346c8d07c88f6cb225341cc5714936fc36db17e815224ba1d2107370694c20420910c86b4aa50d91090'
|
@@ -1,6 +1,22 @@
|
|
1
1
|
module LwqzxAuth
|
2
2
|
class ApplicationController < ::ApplicationController
|
3
3
|
protect_from_forgery with: :exception
|
4
|
-
|
4
|
+
before_action :check_me
|
5
|
+
def check_me
|
6
|
+
auth_token = cookies.signed[:auth_token]
|
7
|
+
unless auth_token.blank?
|
8
|
+
one = Remember.where(token: auth_token).first
|
9
|
+
if one
|
10
|
+
if one.expired > Time.now.to_i
|
11
|
+
session[:login] = one.login
|
12
|
+
session[:realname] = one.name
|
13
|
+
session[:groups] = one.groups
|
14
|
+
else
|
15
|
+
cookies.delete(:auth_token)
|
16
|
+
one.delete
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
5
21
|
end
|
6
22
|
end
|
@@ -8,6 +8,13 @@ module LwqzxAuth
|
|
8
8
|
|
9
9
|
def logout
|
10
10
|
flash[:notice]="你已经登出"
|
11
|
+
|
12
|
+
auth_token = cookies[:auth_token]
|
13
|
+
unless auth_token.blank?
|
14
|
+
one = Remember.where(token: auth_token).first
|
15
|
+
cookies.delete(:auth_token)
|
16
|
+
one.delete if one
|
17
|
+
end
|
11
18
|
reset_session
|
12
19
|
redirect_to main_app.root_path
|
13
20
|
end
|
@@ -20,6 +27,7 @@ module LwqzxAuth
|
|
20
27
|
|
21
28
|
login = params[:login]
|
22
29
|
psd = params[:password]
|
30
|
+
|
23
31
|
hsh = lauth(login,psd)
|
24
32
|
if hsh["name"].blank?
|
25
33
|
redirect_to login_path , alert: "用户信息有误"
|
@@ -27,6 +35,18 @@ module LwqzxAuth
|
|
27
35
|
login = hsh["login"]
|
28
36
|
name = hsh["name"]
|
29
37
|
groups = hsh["user_group"]
|
38
|
+
|
39
|
+
#rememberme = params[:rememberme]
|
40
|
+
#if rememberme == "yes"
|
41
|
+
# token = SecureRandom.urlsafe_base64
|
42
|
+
# cookies.signed[:auth_token] = token
|
43
|
+
# Remember.create(token: token, login: login, name: name, groups: groups,expired: 7.days.from_now.to_i)
|
44
|
+
#else
|
45
|
+
# auth_token = cookies[:auth_token]
|
46
|
+
# cookies.delete(:auth_token)
|
47
|
+
# Remember.where(token: auth_token).delete
|
48
|
+
#end
|
49
|
+
|
30
50
|
session[:login] = login
|
31
51
|
session[:realname] = name
|
32
52
|
session[:groups] = groups
|
@@ -35,6 +55,7 @@ module LwqzxAuth
|
|
35
55
|
end
|
36
56
|
|
37
57
|
private
|
58
|
+
|
38
59
|
def lauth(login,passwd)
|
39
60
|
lurl = "http://www.lwqzx.sdedu.net/kernel/net_school/core/jslogin.php"
|
40
61
|
res = ::RestClient.post lurl,{login: login, password: passwd}
|
@@ -1,22 +1,20 @@
|
|
1
1
|
h2.text-center =<> icon("fas","user") + ' 登 录'
|
2
2
|
br
|
3
3
|
.row
|
4
|
-
.col-
|
5
|
-
.col-sm-4
|
4
|
+
.col-12.col-md-4.offset-md-4.align-self-center
|
6
5
|
= form_tag auth_path, role: "form", class: "loginForm card form-horizontal" do
|
7
6
|
.card-body
|
8
|
-
strong 登录名
|
7
|
+
p: strong 登录名
|
8
|
+
div = text_field_tag :login,nil,class: "form-control login"
|
9
9
|
br
|
10
|
-
|
11
|
-
|
12
|
-
strong 密码:
|
13
|
-
br
|
14
|
-
= password_field_tag :password,nil, class: "form-control password"
|
10
|
+
p: strong 密码
|
11
|
+
div = password_field_tag :password,nil, class: "form-control password"
|
15
12
|
p.text-center
|
16
13
|
a.rucaptcha-image-box href="#" = rucaptcha_image_tag
|
17
14
|
p.text-center = rucaptcha_input_tag(class: 'form-control code',placeholder: "输入验证码")
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
15
|
+
/p.text-center
|
16
|
+
=<> check_box_tag :rememberme, "yes", false
|
17
|
+
| 记住7天
|
18
|
+
div.mt-3
|
19
|
+
= submit_tag '登录', class: "btn-block btn-primary btn btn-lg"
|
20
|
+
/.card-footer
|
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.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- zxy
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-12-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -40,6 +40,7 @@ files:
|
|
40
40
|
- app/controllers/lwqzx_auth/application_controller.rb
|
41
41
|
- app/controllers/lwqzx_auth/auth_controller.rb
|
42
42
|
- app/helpers/lwqzx_auth/application_helper.rb
|
43
|
+
- app/models/lwqzx_auth/remember.rb
|
43
44
|
- app/views/lwqzx_auth/auth/login.html.slim
|
44
45
|
- config/initializers/rucaptcha.rb
|
45
46
|
- config/routes.rb
|
@@ -66,7 +67,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
66
67
|
- !ruby/object:Gem::Version
|
67
68
|
version: '0'
|
68
69
|
requirements: []
|
69
|
-
rubygems_version: 3.
|
70
|
+
rubygems_version: 3.1.4
|
70
71
|
signing_key:
|
71
72
|
specification_version: 4
|
72
73
|
summary: add auth function to host application.
|