mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-13 19:54:02 +00:00
Merge branch 'master' into ssl-opt
This commit is contained in:
commit
ee6040ffd6
7 changed files with 68 additions and 9 deletions
7
Gemfile
7
Gemfile
|
|
@ -44,6 +44,9 @@ gem 'omniauth-openid'
|
||||||
gem 'omniauth-google-oauth2'
|
gem 'omniauth-google-oauth2'
|
||||||
gem 'omniauth-github'
|
gem 'omniauth-github'
|
||||||
|
|
||||||
|
# Bot-filtering
|
||||||
|
gem 'recaptcha', require: 'recaptcha/rails'
|
||||||
|
|
||||||
# as authorization framework
|
# as authorization framework
|
||||||
gem 'cancancan'
|
gem 'cancancan'
|
||||||
|
|
||||||
|
|
@ -182,6 +185,10 @@ gem 'cloudinary'
|
||||||
# for setting app configuration in the environment
|
# for setting app configuration in the environment
|
||||||
gem 'dotenv-rails'
|
gem 'dotenv-rails'
|
||||||
|
|
||||||
|
# configurable toggles for functionality
|
||||||
|
# https://github.com/mgsnova/feature
|
||||||
|
gem 'feature'
|
||||||
|
|
||||||
# For countable.js
|
# For countable.js
|
||||||
gem "countable-rails", "~> 0.0.1"
|
gem "countable-rails", "~> 0.0.1"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -179,6 +179,7 @@ GEM
|
||||||
multipart-post (>= 1.2, < 3)
|
multipart-post (>= 1.2, < 3)
|
||||||
fastimage (2.0.0)
|
fastimage (2.0.0)
|
||||||
addressable (~> 2)
|
addressable (~> 2)
|
||||||
|
feature (1.4.0)
|
||||||
ffi (1.9.18)
|
ffi (1.9.18)
|
||||||
font-awesome-rails (4.7.0.2)
|
font-awesome-rails (4.7.0.2)
|
||||||
railties (>= 3.2, < 5.2)
|
railties (>= 3.2, < 5.2)
|
||||||
|
|
@ -420,6 +421,8 @@ GEM
|
||||||
loggability (~> 0.12)
|
loggability (~> 0.12)
|
||||||
rdoc (~> 5.0)
|
rdoc (~> 5.0)
|
||||||
yajl-ruby (~> 1.3)
|
yajl-ruby (~> 1.3)
|
||||||
|
recaptcha (4.6.2)
|
||||||
|
json
|
||||||
redcarpet (3.2.3)
|
redcarpet (3.2.3)
|
||||||
referer-parser (0.2.1)
|
referer-parser (0.2.1)
|
||||||
request_store (1.1.0)
|
request_store (1.1.0)
|
||||||
|
|
@ -589,6 +592,7 @@ DEPENDENCIES
|
||||||
dotenv-rails
|
dotenv-rails
|
||||||
factory_girl_rails
|
factory_girl_rails
|
||||||
faker
|
faker
|
||||||
|
feature
|
||||||
font-awesome-rails
|
font-awesome-rails
|
||||||
formtastic (~> 3.1.1)
|
formtastic (~> 3.1.1)
|
||||||
formtastic-bootstrap
|
formtastic-bootstrap
|
||||||
|
|
@ -636,6 +640,7 @@ DEPENDENCIES
|
||||||
rails-i18n (~> 4.0.0)
|
rails-i18n (~> 4.0.0)
|
||||||
rails_12factor
|
rails_12factor
|
||||||
rdoc-generator-fivefish
|
rdoc-generator-fivefish
|
||||||
|
recaptcha
|
||||||
redcarpet
|
redcarpet
|
||||||
responders (~> 2.0)
|
responders (~> 2.0)
|
||||||
rolify
|
rolify
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
@import "bootstrap/mixins";
|
||||||
|
|
||||||
html {
|
html {
|
||||||
position: relative;
|
position: relative;
|
||||||
min-height: 100%;
|
min-height: 100%;
|
||||||
|
|
@ -104,3 +106,12 @@ p.comment-body {
|
||||||
.qr-image{
|
.qr-image{
|
||||||
margin-left: 120px;
|
margin-left: 120px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.g-recaptcha {
|
||||||
|
@include clearfix;
|
||||||
|
padding-bottom: 12px;
|
||||||
|
|
||||||
|
div {
|
||||||
|
float: right;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
class RegistrationsController < Devise::RegistrationsController
|
class RegistrationsController < Devise::RegistrationsController
|
||||||
before_action :configure_permitted_parameters, if: :devise_controller?
|
prepend_before_action :check_captcha, only: [:create]
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
@openids = Openid.where(user_id: current_user.id).order(:provider)
|
@openids = Openid.where(user_id: current_user.id).order(:provider)
|
||||||
|
|
@ -21,14 +21,34 @@ class RegistrationsController < Devise::RegistrationsController
|
||||||
edit_user_registration_path(resource)
|
edit_user_registration_path(resource)
|
||||||
end
|
end
|
||||||
|
|
||||||
def configure_permitted_parameters
|
private
|
||||||
devise_parameter_sanitizer.permit(:account_update) do |u|
|
|
||||||
u
|
def sign_up_params
|
||||||
.permit(:email, :password, :password_confirmation, :current_password, :username, :email_public)
|
params.require(:user).permit(
|
||||||
end
|
:email,
|
||||||
devise_parameter_sanitizer.permit(:sign_up) do |u|
|
:password,
|
||||||
u
|
:password_confirmation,
|
||||||
.permit(:email, :password, :password_confirmation, :name, :username)
|
:name,
|
||||||
|
:username
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
def account_update_params
|
||||||
|
params.require(:user).permit(
|
||||||
|
:email,
|
||||||
|
:password,
|
||||||
|
:password_confirmation,
|
||||||
|
:current_password,
|
||||||
|
:username,
|
||||||
|
:email_public
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
def check_captcha
|
||||||
|
unless Feature.inactive?(:recaptcha) || verify_recaptcha
|
||||||
|
self.resource = resource_class.new sign_up_params
|
||||||
|
resource.validate # Look for any other validation errors besides Recaptcha
|
||||||
|
respond_with_navigational(resource) { render :new }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,8 @@
|
||||||
= f.input :name, input_html: { required: true }, hint: 'This is your real name'
|
= f.input :name, input_html: { required: true }, hint: 'This is your real name'
|
||||||
= f.input :password, input_html: { required: true }
|
= f.input :password, input_html: { required: true }
|
||||||
= f.input :password_confirmation, input_html: { required: true }
|
= f.input :password_confirmation, input_html: { required: true }
|
||||||
|
- Feature.with(:recaptcha) do
|
||||||
|
= recaptcha_tags
|
||||||
%p.text-right
|
%p.text-right
|
||||||
= f.action :submit, as: :button, label: 'Sign Up', button_html: { class: 'btn btn-success' }
|
= f.action :submit, as: :button, label: 'Sign Up', button_html: { class: 'btn btn-success' }
|
||||||
|
|
||||||
|
|
|
||||||
10
config/initializers/feature.rb
Normal file
10
config/initializers/feature.rb
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
require 'feature'
|
||||||
|
|
||||||
|
repo = Feature::Repository::SimpleRepository.new
|
||||||
|
|
||||||
|
# configure features here
|
||||||
|
unless(ENV['RECAPTCHA_SITE_KEY'].blank? || ENV['RECAPTCHA_SECRET_KEY'].blank?)
|
||||||
|
repo.add_active_feature :recaptcha
|
||||||
|
end
|
||||||
|
|
||||||
|
Feature.set_repository repo
|
||||||
|
|
@ -66,3 +66,7 @@ OSEM_ICHAIN_ENABLED=false
|
||||||
|
|
||||||
# enable this to force SSL
|
# enable this to force SSL
|
||||||
# FORCE_SSL="1"
|
# FORCE_SSL="1"
|
||||||
|
|
||||||
|
# ReCAPTCHA keys
|
||||||
|
RECAPTCHA_SITE_KEY=""
|
||||||
|
RECAPTCHA_SECRET_KEY=""
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue