try to stop bots (part2)

This commit is contained in:
Alexander Machehin 2013-08-28 21:15:28 +06:00
parent 01380be9a7
commit 5c6220a46d
11 changed files with 28 additions and 3 deletions

View File

@ -32,4 +32,6 @@ $(document).ready(function() {
} }
return true; return true;
}); });
$('#recaptcha_response_field').val('');
}); });

View File

@ -80,7 +80,7 @@ class ApplicationController < ActionController::Base
end end
def layout_by_resource def layout_by_resource
if devise_controller? && !(params[:controller] == 'devise/registrations' && ['edit', 'update'].include?(params[:action])) if devise_controller?
"sessions" "sessions"
else else
"application" "application"

View File

@ -0,0 +1,11 @@
class Users::RegistrationsController < Devise::RegistrationsController
# POST /resource
def create
# Try stop bots
if params[:recaptcha_response_field].present?
respond_with(resource, :location => after_inactive_sign_up_path_for(resource))
return
end
super
end
end

View File

@ -7,6 +7,7 @@
%article %article
= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :class => "form" }) do |f| = form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :class => "form" }) do |f|
= hidden_field_tag :invitation_token, @invitation_token = hidden_field_tag :invitation_token, @invitation_token
= f.password_field :password, :name => 'password', :style => 'display: none;'
.left.first=t('activerecord.attributes.user.uname') .left.first=t('activerecord.attributes.user.uname')
.right.first .right.first
= f.text_field :uname, :id => 'login', :class => "registartion-input #{uname_error ? 'registartion-input-error' : ''}" = f.text_field :uname, :id => 'login', :class => "registartion-input #{uname_error ? 'registartion-input-error' : ''}"
@ -34,6 +35,8 @@
.in .in
=f.submit t("layout.devise.shared_links.sign_up"), :class => 'button', :id => 'btnLogin' =f.submit t("layout.devise.shared_links.sign_up"), :class => 'button', :id => 'btnLogin'
.both .both
= hidden_field_tag :recaptcha_challenge_field
= hidden_field_tag :recaptcha_response_field, 'manual_challenge'
= render 'devise/shared/providers' = render 'devise/shared/providers'
=showDeviseHintError(:login, uname_error) =showDeviseHintError(:login, uname_error)

View File

@ -0,0 +1,2 @@
%noscript
%div{:style => 'font-size: 12px; color: red; font-weight: bold;'}= t 'layout.noscript_message'

View File

@ -47,6 +47,7 @@
- if content_for?(:feed_tabs) - if content_for?(:feed_tabs)
= yield :feed_tabs = yield :feed_tabs
.both .both
= render 'layouts/noscript'
= render "layouts/flashes" = render "layouts/flashes"
= render "layouts/notifies" = render "layouts/notifies"
%article %article

View File

@ -13,7 +13,7 @@
= display_meta_tags :site => APP_CONFIG['project_name'], :reverse => true, :separator => '-' = display_meta_tags :site => APP_CONFIG['project_name'], :reverse => true, :separator => '-'
%body %body
-# render "layouts/flashes" = render 'layouts/noscript'
= yield = yield
= render 'layouts/counters' unless current_user.try(:admin?) = render 'layouts/counters' unless current_user.try(:admin?)

View File

@ -42,6 +42,7 @@
.tour .tour
=image_tag "tour-top#{I18n.locale == :en ? '-eng' : ''}.png", :alt => 'ABF' =image_tag "tour-top#{I18n.locale == :en ? '-eng' : ''}.png", :alt => 'ABF'
.both .both
= render 'layouts/noscript'
= render 'layouts/flashes' = render 'layouts/flashes'
%article %article
= yield = yield

View File

@ -52,6 +52,7 @@ en:
atom_link_tag_title: Private feed for %{nickname} | %{app_name} atom_link_tag_title: Private feed for %{nickname} | %{app_name}
preview: Preview preview: Preview
link: Link link: Link
noscript_message: You need javascript to properly use this site
settings: settings:
label: Settings label: Settings

View File

@ -52,6 +52,7 @@ ru:
atom_link_tag_title: Приватная лента для %{nickname} | %{app_name} atom_link_tag_title: Приватная лента для %{nickname} | %{app_name}
preview: Предосмотр preview: Предосмотр
link: Ссылка link: Ссылка
noscript_message: Включите javascript для корректной работы сайта
settings: settings:
label: 'Настройки' label: 'Настройки'

View File

@ -8,7 +8,10 @@ Rosa::Application.routes.draw do
devise_scope :users do devise_scope :users do
get '/users/auth/:provider' => 'users/omniauth_callbacks#passthru' get '/users/auth/:provider' => 'users/omniauth_callbacks#passthru'
end end
devise_for :users, :controllers => {:omniauth_callbacks => 'users/omniauth_callbacks'} devise_for :users, :controllers => {:omniauth_callbacks => 'users/omniauth_callbacks'}, :skip => [:registrations] do
get 'users/sign_up' => 'users/registrations#new', :as => :new_user_registration
post 'users' => 'users/registrations#create', :as => :user_registration
end
namespace :api do namespace :api do
namespace :v1 do namespace :v1 do