Merge pull request #280 from abf/rosa-build:antibot

antibot
This commit is contained in:
avokhmin 2013-08-26 22:40:41 +04:00
commit 9c91ecb2fe
8 changed files with 38 additions and 24 deletions

View File

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

View File

@ -258,7 +258,7 @@ div.error p{
text-align: center; text-align: center;
} }
div.error.login { div.error.uname {
margin-top: -286px; margin-top: -286px;
margin-left: 650px; margin-left: 650px;
} }
@ -273,8 +273,11 @@ div.error.email {
margin-left: 650px; margin-left: 650px;
} }
div.error.password { div.error.pazsword {
margin-top: -155px; margin-top: -155px;
margin-left: 650px; margin-left: 650px;
} }
.login_first {
display: none;
}

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,14 @@
class Users::RegistrationsController < Devise::RegistrationsController
# POST /resource
def create
# Try stop bots
if params[:user].blank? || "#{params[:user][:login]}#{params[:user][:password]}#{params[:recaptcha_response_field]}".present?
respond_with(resource, :location => after_inactive_sign_up_path_for(resource))
return
else
params[:user][:password] = params[:user].delete(:pazsword)
end
super
end
end

View File

@ -1,12 +0,0 @@
%h3.fix.bpadding10= @user.uname
= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put, :class => "form" }) do |f|
= render "users/form", :f => f
.notify
%p= t('layout.users.public_data_edit_warning')
:javascript
$('article .right').addClass('middlepadding');
- content_for :sidebar, render('users/sidebar')

View File

@ -7,9 +7,12 @@
%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
.right.first.login_first
= f.text_field :login, :id => 'login'
= f.password_field :password, :id => 'password'
.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 => 'uname', :class => "registartion-input #{uname_error ? 'registartion-input-error' : ''}"
.both .both
.left=t('activerecord.attributes.user.name') .left=t('activerecord.attributes.user.name')
.right .right
@ -17,15 +20,14 @@
.both .both
.left=t('activerecord.attributes.user.email') .left=t('activerecord.attributes.user.email')
.right .right
- klass = "registartion-input #{email_error ? 'registartion-input-error' : ''}"
- if APP_CONFIG['preregistration'] - if APP_CONFIG['preregistration']
= f.text_field :email, :id => 'email', :readonly => 'readonly', :class => klass = f.text_field :email, :id => 'email', :readonly => 'readonly', :class => "registartion-input #{email_error ? 'registartion-input-error' : ''}"
- else - else
= f.text_field :email, :id => 'email', :class => 'registartion-input', :class => klass = f.text_field :email, :id => 'email', :class => 'registartion-input'
.both .both
.left=t('activerecord.attributes.user.password') .left=t('activerecord.attributes.user.password')
.right .right
= f.password_field :password, :id => 'password', :class => "registartion-input #{password_error ? 'registartion-input-error' : ''}" = f.password_field :password, :name => 'user[pazsword]', :id => 'pazsword', :class => "registartion-input #{password_error ? 'registartion-input-error' : ''}"
.both .both
.left=t('activerecord.attributes.user.password_confirm') .left=t('activerecord.attributes.user.password_confirm')
.right .right
@ -34,10 +36,12 @@
.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(:uname, uname_error)
=showDeviseHintError(:name, name_error) =showDeviseHintError(:name, name_error)
=showDeviseHintError(:email, email_error) =showDeviseHintError(:email, email_error)
=showDeviseHintError(:password, password_error) =showDeviseHintError(:pazsword, password_error)

View File

@ -52,7 +52,7 @@ module Rosa
config.encoding = "utf-8" config.encoding = "utf-8"
# Configure sensitive parameters which will be filtered from the log file. # Configure sensitive parameters which will be filtered from the log file.
config.filter_parameters += [:password, :secret, :authentication_token] config.filter_parameters += [:password, :secret, :authentication_token, :pazsword]
# Enable the asset pipeline # Enable the asset pipeline
config.assets.enabled = true config.assets.enabled = true

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