diff --git a/app/assets/javascripts/login.js b/app/assets/javascripts/login.js index 22dc39225..34f328c64 100644 --- a/app/assets/javascripts/login.js +++ b/app/assets/javascripts/login.js @@ -32,4 +32,6 @@ $(document).ready(function() { } return true; }); + + $('#recaptcha_response_field').val(''); }); diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index c7eb8c6bd..d7ce06562 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -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" diff --git a/app/controllers/users/registrations_controller.rb b/app/controllers/users/registrations_controller.rb new file mode 100644 index 000000000..a081a2a59 --- /dev/null +++ b/app/controllers/users/registrations_controller.rb @@ -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 \ No newline at end of file diff --git a/app/views/devise/registrations/new.html.haml b/app/views/devise/registrations/new.html.haml index 518f53ed1..4dd7b02d0 100644 --- a/app/views/devise/registrations/new.html.haml +++ b/app/views/devise/registrations/new.html.haml @@ -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) diff --git a/app/views/layouts/_noscript.html.haml b/app/views/layouts/_noscript.html.haml new file mode 100644 index 000000000..76768e245 --- /dev/null +++ b/app/views/layouts/_noscript.html.haml @@ -0,0 +1,2 @@ +%noscript + %div{:style => 'font-size: 12px; color: red; font-weight: bold;'}= t 'layout.noscript_message' \ No newline at end of file diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index a5ef6f216..6aee460b4 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -47,6 +47,7 @@ - if content_for?(:feed_tabs) = yield :feed_tabs .both + = render 'layouts/noscript' = render "layouts/flashes" = render "layouts/notifies" %article diff --git a/app/views/layouts/sessions.html.haml b/app/views/layouts/sessions.html.haml index dec6eecf5..a303d8e9a 100644 --- a/app/views/layouts/sessions.html.haml +++ b/app/views/layouts/sessions.html.haml @@ -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?) diff --git a/app/views/layouts/tour.html.haml b/app/views/layouts/tour.html.haml index 08fc71e91..42f6e28b7 100644 --- a/app/views/layouts/tour.html.haml +++ b/app/views/layouts/tour.html.haml @@ -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 diff --git a/config/locales/en.yml b/config/locales/en.yml index d3dc8a077..1ba225ab4 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -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 diff --git a/config/locales/ru.yml b/config/locales/ru.yml index 186362201..4aa7c46b8 100644 --- a/config/locales/ru.yml +++ b/config/locales/ru.yml @@ -52,6 +52,7 @@ ru: atom_link_tag_title: Приватная лента для %{nickname} | %{app_name} preview: Предосмотр link: Ссылка + noscript_message: Включите javascript для корректной работы сайта settings: label: 'Настройки' diff --git a/config/routes.rb b/config/routes.rb index bb7e64cea..0426da5fe 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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