File: topics_controller.rb

package info (click to toggle)
ruby-invisible-captcha 2.3.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 384 kB
  • sloc: ruby: 717; makefile: 6
file content (84 lines) | stat: -rw-r--r-- 1,698 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
class TopicsController < ApplicationController
  invisible_captcha honeypot: :subtitle, only: :create

  invisible_captcha honeypot: :subtitle, only: :update,
                              on_spam: :custom_callback,
                              on_timestamp_spam: :custom_timestamp_callback

  invisible_captcha honeypot: :subtitle, only: :publish, timestamp_threshold: 2

  invisible_captcha honeypot: :subtitle, only: :copy, timestamp_enabled: false

  invisible_captcha scope: :topic, only: :rename

  invisible_captcha only: :categorize

  invisible_captcha honeypot: :subtitle, only: :test_passthrough,
    on_spam: :catching_on_spam_callback,
    on_timestamp_spam: :on_timestamp_spam_callback_with_passthrough

  def index
    redirect_to new_topic_path
  end

  def new
    @topic = Topic.new
  end

  def create
    @topic = Topic.new(params[:topic])

    if @topic.valid?
      redirect_to new_topic_path(context: params[:context]), notice: 'Topic valid!'
    else
      render action: 'new'
    end
  end

  def update
    redirect_to new_topic_path
  end

  def rename
  end

  def categorize
    redirect_to new_topic_path
  end

  def publish
    redirect_to new_topic_path
  end

  def copy
    @topic = Topic.new(params[:topic])

    if @topic.valid?
      redirect_to new_topic_path(context: params[:context]), notice: 'Success!'
    else
      render action: 'new'
    end
  end

  def test_passthrough
    redirect_to new_topic_path
  end

  private

  def custom_callback
    redirect_to new_topic_path
  end

  def custom_timestamp_callback
    head(204)
  end

  def on_timestamp_spam_callback_with_passthrough
  end

  def catching_on_spam_callback
    head(204)
  end

end