antispam 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/app/controllers/antispam/application_controller.rb +11 -4
- data/app/controllers/antispam/blocks_controller.rb +1 -43
- data/app/controllers/antispam/clears_controller.rb +0 -35
- data/lib/antispam.rb +11 -11
- data/lib/antispam/version.rb +3 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c7ff53aa93e140a619d1066589af51f818da3fefaf5444c6c03f02a1dce03130
|
4
|
+
data.tar.gz: d5aa2c041784330af13fa472aea02dfb5950d0c68ca4dd1f72a8414198c0601b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ae41d1216a47c3035e572a4c9646d4e29cfc022fff6010a878ed1bc31d2160bdfc1ce2f615e96d116517955cec18756111e1207ac0e4de384edcc010a30b0897
|
7
|
+
data.tar.gz: 983b88669af0fe6297ae47aab7379c559df7ea9a7144e3f93617ce67f6e4c8953ad27f7f23c7f525ba810c0b40b14301628ffd40dc881172a7e37c88645d0676
|
data/README.md
CHANGED
@@ -27,7 +27,7 @@ You need to add this to your routes.rb
|
|
27
27
|
mount Antispam::Engine => "/antispam"
|
28
28
|
```
|
29
29
|
You can see what IP addresses have been blocked by going to /antispam/blocks
|
30
|
-
but your applicationcontroller must
|
30
|
+
but your applicationcontroller must respond to ```is_admin?``` function.
|
31
31
|
|
32
32
|
|
33
33
|
## Installation
|
@@ -1,4 +1,11 @@
|
|
1
|
-
module Antispam
|
2
|
-
class ApplicationController <
|
3
|
-
|
4
|
-
|
1
|
+
module Antispam
|
2
|
+
class ApplicationController < ::ApplicationController
|
3
|
+
def must_be_admin
|
4
|
+
begin
|
5
|
+
render plain: 'Not available.' unless is_admin?
|
6
|
+
rescue
|
7
|
+
render plain: 'Not available.'
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -3,7 +3,7 @@ require_dependency "antispam/application_controller"
|
|
3
3
|
module Antispam
|
4
4
|
class BlocksController < ApplicationController
|
5
5
|
before_action :must_be_admin
|
6
|
-
before_action :set_block, only: [:show
|
6
|
+
before_action :set_block, only: [:show]
|
7
7
|
|
8
8
|
# GET /blocks
|
9
9
|
def index
|
@@ -14,41 +14,6 @@ module Antispam
|
|
14
14
|
def show
|
15
15
|
end
|
16
16
|
|
17
|
-
# # GET /blocks/new
|
18
|
-
# def new
|
19
|
-
# @block = Block.new
|
20
|
-
# end
|
21
|
-
#
|
22
|
-
# # GET /blocks/1/edit
|
23
|
-
# def edit
|
24
|
-
# end
|
25
|
-
#
|
26
|
-
# # POST /blocks
|
27
|
-
# def create
|
28
|
-
# @block = Block.new(block_params)
|
29
|
-
#
|
30
|
-
# if @block.save
|
31
|
-
# redirect_to @block, notice: 'Block was successfully created.'
|
32
|
-
# else
|
33
|
-
# render :new
|
34
|
-
# end
|
35
|
-
# end
|
36
|
-
#
|
37
|
-
# # PATCH/PUT /blocks/1
|
38
|
-
# def update
|
39
|
-
# if @block.update(block_params)
|
40
|
-
# redirect_to @block, notice: 'Block was successfully updated.'
|
41
|
-
# else
|
42
|
-
# render :edit
|
43
|
-
# end
|
44
|
-
# end
|
45
|
-
#
|
46
|
-
# # DELETE /blocks/1
|
47
|
-
# def destroy
|
48
|
-
# @block.destroy
|
49
|
-
# redirect_to blocks_url, notice: 'Block was successfully destroyed.'
|
50
|
-
# end
|
51
|
-
|
52
17
|
private
|
53
18
|
# Use callbacks to share common setup or constraints between actions.
|
54
19
|
def set_block
|
@@ -59,12 +24,5 @@ module Antispam
|
|
59
24
|
def block_params
|
60
25
|
params.require(:block).permit(:ip, :provider, :controllername, :actionname)
|
61
26
|
end
|
62
|
-
def must_be_admin
|
63
|
-
begin
|
64
|
-
return false unless user_has_role?("admin")
|
65
|
-
rescue
|
66
|
-
return false
|
67
|
-
end
|
68
|
-
end
|
69
27
|
end
|
70
28
|
end
|
@@ -13,41 +13,6 @@ module Antispam
|
|
13
13
|
# GET /clears/1
|
14
14
|
def show
|
15
15
|
end
|
16
|
-
#
|
17
|
-
# # GET /clears/new
|
18
|
-
# def new
|
19
|
-
# @clear = Clear.new
|
20
|
-
# end
|
21
|
-
#
|
22
|
-
# # GET /clears/1/edit
|
23
|
-
# def edit
|
24
|
-
# end
|
25
|
-
#
|
26
|
-
# # POST /clears
|
27
|
-
# def create
|
28
|
-
# @clear = Clear.new(clear_params)
|
29
|
-
#
|
30
|
-
# if @clear.save
|
31
|
-
# redirect_to @clear, notice: 'Clear was successfully created.'
|
32
|
-
# else
|
33
|
-
# render :new
|
34
|
-
# end
|
35
|
-
# end
|
36
|
-
#
|
37
|
-
# # PATCH/PUT /clears/1
|
38
|
-
# def update
|
39
|
-
# if @clear.update(clear_params)
|
40
|
-
# redirect_to @clear, notice: 'Clear was successfully updated.'
|
41
|
-
# else
|
42
|
-
# render :edit
|
43
|
-
# end
|
44
|
-
# end
|
45
|
-
#
|
46
|
-
# # DELETE /clears/1
|
47
|
-
# def destroy
|
48
|
-
# @clear.destroy
|
49
|
-
# redirect_to clears_url, notice: 'Clear was successfully destroyed.'
|
50
|
-
# end
|
51
16
|
|
52
17
|
private
|
53
18
|
# Use callbacks to share common setup or constraints between actions.
|
data/lib/antispam.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
require "antispam/version"
|
2
|
-
require "antispam/engine"
|
3
|
-
require "antispam/tools"
|
4
|
-
require "antispam/blacklists/httpbl"
|
5
|
-
|
6
|
-
module Antispam
|
7
|
-
ActiveSupport.on_load(:action_controller) do
|
8
|
-
# self refers to ActionController::Base here
|
9
|
-
self.include Antispam::Tools
|
10
|
-
end
|
11
|
-
end
|
1
|
+
require "antispam/version"
|
2
|
+
require "antispam/engine"
|
3
|
+
require "antispam/tools"
|
4
|
+
require "antispam/blacklists/httpbl"
|
5
|
+
|
6
|
+
module Antispam
|
7
|
+
ActiveSupport.on_load(:action_controller) do
|
8
|
+
# self refers to ActionController::Base here
|
9
|
+
self.include Antispam::Tools
|
10
|
+
end
|
11
|
+
end
|
data/lib/antispam/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
module Antispam
|
2
|
-
VERSION = '0.1.
|
3
|
-
end
|
1
|
+
module Antispam
|
2
|
+
VERSION = '0.1.1'
|
3
|
+
end
|