lwqzx_auth 0.0.9 → 0.1.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
  SHA256:
3
- metadata.gz: 20218c425d0a074da1a3b19fdfb5696e416928c4678b5a241363e034f4d94e0c
4
- data.tar.gz: 87764ec7f26a5cf667719bd8a0fe39b2ce343449783590fe9e81c26ccc8bf8a3
3
+ metadata.gz: 03257e86f6cb105bb53fae5e7057715a68f6faed674c1692152152ef639bd7ac
4
+ data.tar.gz: 8aaa15c6dce50df06612bcee7c11cbcd67d568f80abc41c772d93ddac35d6f6b
5
5
  SHA512:
6
- metadata.gz: 8051249dfea2188d85243ffa854e25dbaea512a1766222aceba59b37610fb41f0f36430b2b3200e0ad57c7f958ebd647f4182719b7e1703caa0dc817859acfc2
7
- data.tar.gz: 83f7eab3501fa49f7aa6221251afe5cf7e9ada352521e5e32396f005e980575e4c0e942b5417c137409bd45af96781b0f63ce183375c526795bbf08db2d73f40
6
+ metadata.gz: 341a0dc82697c61963097b216261c0c585073bbb77cae98c0e1a4f3def826a66a7aa4d00806b7e90eee21c8b30946b6255e298409bdbe179356d7bc940d3964b
7
+ data.tar.gz: e993a4bfa02902a0fdd9aee1425556fea7ac07b22dbf2f222caffccd74538a7719ee4c78465afd348fe47ac7d314528de567cfb17319215ee2d483116dadd39b
data/README.md CHANGED
@@ -21,8 +21,18 @@ Or install it yourself as:
21
21
  $ gem install lwqzx_auth
22
22
  ```
23
23
 
24
- ## Contributing
25
- Contribution directions go here.
24
+ ## method added
25
+
26
+ attachit : can be used in controller to add tempfile to mongodb
27
+
28
+ ```ruby
29
+ group[:logo] = attachit("group",:logo)
30
+ ```
31
+ pageit: can be used in controller for page model
32
+
33
+ is_login? : can be used in controller or views to test login status
34
+
35
+ need_login: can be used in controller
26
36
 
27
37
  ## License
28
38
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
@@ -1,7 +1,43 @@
1
1
  module LwqzxAuth
2
- module ApplicationHelper
3
- def is_login?
4
- !!session[:login]
5
- end
6
- end
2
+ module ApplicationHelper
3
+ def is_login?
4
+ !!session[:login]
5
+ end
6
+
7
+ end
8
+
9
+ module ApplicationOnly
10
+
11
+ def need_login
12
+ unless is_login?
13
+ flash[:alert] = "你还没有登录"
14
+ redirect_to lwqzx_auth.login_path and return
15
+ end
16
+ end
17
+
18
+ def pageit
19
+ params[:page] ||= 1
20
+ per_page = 10
21
+ @num=per_page*(params[:page].to_i-1)
22
+ end
23
+
24
+ def attachit(model,attach = :attach)
25
+ unless params[model.to_sym][attach].blank?
26
+ if params[:action] == 'update'
27
+ old_attach = eval("@#{model}.#{attach.to_s}")
28
+ unless old_attach.blank?
29
+ id = BSON::ObjectId.from_string(old_attach['grid_id'])
30
+ MongoGrid.grid.delete(id)
31
+ end
32
+ end
33
+ attach=params[model.to_sym][attach]
34
+ MongoGrid.uploadtogrid(attach,width: 300)
35
+ else
36
+ if params[:action] == 'update'
37
+ old_attach = eval("@#{model}.#{attach.to_s}")
38
+ return old_attach.blank? ? {} : old_attach
39
+ end
40
+ end
41
+ end
42
+ end
7
43
  end
@@ -1,8 +1,8 @@
1
1
  h2.text-center =<> icon("fas","user") + ' 登 录'
2
2
  br
3
3
  .row
4
- .col-md-4
5
- .col-md-4
4
+ .col-sm-4
5
+ .col-sm-4
6
6
  = form_tag auth_path, role: "form", class: "card form-horizontal" do
7
7
  .card-body
8
8
  strong 登录名
@@ -12,7 +12,8 @@ br
12
12
  strong 密码:
13
13
  br
14
14
  = password_field_tag :password,nil, class: "form-control"
15
-
16
15
 
17
16
  .card-footer
18
17
  = submit_tag '登录', class: "btn-block btn-primary btn"
18
+
19
+ .col-sm-4
@@ -5,6 +5,7 @@ module LwqzxAuth
5
5
  config.before_initialize do
6
6
  ActiveSupport.on_load :action_controller do
7
7
  include LwqzxAuth::ApplicationHelper
8
+ include LwqzxAuth::ApplicationOnly
8
9
  end
9
10
 
10
11
  ActiveSupport.on_load :action_view do
@@ -1,3 +1,3 @@
1
1
  module LwqzxAuth
2
- VERSION = '0.0.9'
2
+ VERSION = '0.1.3'
3
3
  end
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lwqzx_auth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - zxy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-05 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: rails
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: 5.1.0
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: 5.1.0
11
+ date: 2018-10-08 00:00:00.000000000 Z
12
+ dependencies: []
27
13
  description: auth function into host app.
28
14
  email:
29
15
  - zxy@qq.com
@@ -69,7 +55,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
69
55
  version: '0'
70
56
  requirements: []
71
57
  rubyforge_project:
72
- rubygems_version: 2.7.3
58
+ rubygems_version: 2.7.7
73
59
  signing_key:
74
60
  specification_version: 4
75
61
  summary: add auth function to host application.