Skip to content

Commit

Permalink
add recaptcha to messages (#528)
Browse files Browse the repository at this point in the history
* add recaptcha to messages (fuck spammers!)

* minimize complexity maybe?

* hounded

* thanks helge! :D
  • Loading branch information
gedankenstuecke authored May 31, 2020
1 parent de1fd19 commit 3246af3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions app/controllers/messages_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ def new
def create
@message = Message.new(message_params)

if !verify_recaptcha(model: @user)
redirect_to "/users/#{current_user.id}#messages"
return
end

if @message.save && @message.send_message(@message.from_id, @message.to_id)
flash[:notice] = 'Message sent'
redirect_to "/users/#{current_user.id}#messages"
Expand Down
1 change: 1 addition & 0 deletions app/views/messages/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<%= f.label "body"%>
<%= f.text_area :body, :size => "10x10", class: "form-control" %>
</div>
<p class="signup__recaptcha"><%= recaptcha_tags %></p>
<%= f.submit "Send", :class => "btn btn-default btn-lg"%>
<% end %>
</div>

0 comments on commit 3246af3

Please sign in to comment.