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;
});
$('#recaptcha_response_field').val('');
});

View File

@ -80,7 +80,7 @@ class ApplicationController < ActionController::Base
end
def layout_by_resource
if devise_controller? && !(params[:controller] == 'devise/registrations' && ['edit', 'update'].include?(params[:action]))
if devise_controller?
"sessions"
else
"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
= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :class => "form" }) do |f|
= hidden_field_tag :invitation_token, @invitation_token
= f.password_field :password, :name => 'password', :style => 'display: none;'
.left.first=t('activerecord.attributes.user.uname')
.right.first
= f.text_field :uname, :id => 'login', :class => "registartion-input #{uname_error ? 'registartion-input-error' : ''}"
@ -34,6 +35,8 @@
.in
=f.submit t("layout.devise.shared_links.sign_up"), :class => 'button', :id => 'btnLogin'
.both
= hidden_field_tag :recaptcha_challenge_field
= hidden_field_tag :recaptcha_response_field, 'manual_challenge'
= render 'devise/shared/providers'
=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)
= yield :feed_tabs
.both
= render 'layouts/noscript'
= render "layouts/flashes"
= render "layouts/notifies"
%article

View File

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

View File

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

View File

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

View File

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

View File

@ -8,7 +8,10 @@ Rosa::Application.routes.draw do
devise_scope :users do
get '/users/auth/:provider' => 'users/omniauth_callbacks#passthru'
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 :v1 do