mirror of
https://github.com/Retrospring/retrospring.git
synced 2024-11-20 10:39:54 +01:00
Add ability to disable registrations
This commit is contained in:
parent
2001921163
commit
6cc8ebcba3
7 changed files with 60 additions and 33 deletions
|
@ -1,9 +1,13 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class User::RegistrationsController < Devise::RegistrationsController
|
class User::RegistrationsController < Devise::RegistrationsController
|
||||||
|
before_action :redirect_if_registrations_disabled!, only: %w[create new]
|
||||||
|
|
||||||
def create
|
def create
|
||||||
if captcha_valid?
|
if captcha_valid?
|
||||||
super
|
super
|
||||||
else
|
else
|
||||||
respond_with_navigational(resource){ redirect_to new_user_registration_path }
|
respond_with_navigational(resource) { redirect_to new_user_registration_path }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -18,7 +22,7 @@ class User::RegistrationsController < Devise::RegistrationsController
|
||||||
resource.destroy
|
resource.destroy
|
||||||
set_flash_message :notice, :destroyed if is_flashing_format?
|
set_flash_message :notice, :destroyed if is_flashing_format?
|
||||||
yield resource if block_given?
|
yield resource if block_given?
|
||||||
respond_with_navigational(resource){ redirect_to after_sign_out_path_for(resource_name) }
|
respond_with_navigational(resource) { redirect_to after_sign_out_path_for(resource_name) }
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
@ -29,4 +33,8 @@ class User::RegistrationsController < Devise::RegistrationsController
|
||||||
|
|
||||||
verify_hcaptcha
|
verify_hcaptcha
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def redirect_if_registrations_disabled!
|
||||||
|
redirect_to root_path unless APP_CONFIG.dig(:features, :registration, :enabled)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,12 +5,18 @@
|
||||||
= render "layouts/messages"
|
= render "layouts/messages"
|
||||||
%h1= APP_CONFIG["site_name"]
|
%h1= APP_CONFIG["site_name"]
|
||||||
%p= t(".subtitle")
|
%p= t(".subtitle")
|
||||||
%p
|
- if APP_CONFIG.dig(:features, :registration, :enabled)
|
||||||
%a.btn.btn-outline-light.btn-lg{ href: url_for(new_user_registration_path) }
|
%p
|
||||||
= t(".register")
|
%a.btn.btn-outline-light.btn-lg{ href: url_for(new_user_registration_path) }
|
||||||
%small
|
= t(".register")
|
||||||
= t(".already_member")
|
%small
|
||||||
= link_to t("voc.login"), new_user_session_path
|
= t(".already_member")
|
||||||
|
= link_to t("voc.login"), new_user_session_path
|
||||||
|
- else
|
||||||
|
%p
|
||||||
|
%a.btn.btn-outline-light.btn-lg{ href: url_for(new_user_session_path) }
|
||||||
|
= t("voc.login")
|
||||||
|
|
||||||
.row.my-5.my-sm-10
|
.row.my-5.my-sm-10
|
||||||
.col-sm-6.order-5.order-sm-1.text-center.text-sm-right
|
.col-sm-6.order-5.order-sm-1.text-center.text-sm-right
|
||||||
%h2.mb-4= t(".questions.header")
|
%h2.mb-4= t(".questions.header")
|
||||||
|
@ -77,12 +83,13 @@
|
||||||
= t(".your_data.header")
|
= t(".your_data.header")
|
||||||
%p= t(".your_data.body", app_name: APP_CONFIG["site_name"])
|
%p= t(".your_data.body", app_name: APP_CONFIG["site_name"])
|
||||||
|
|
||||||
.card
|
- if APP_CONFIG.dig(:features, :registration, :enabled)
|
||||||
.card-body
|
.card
|
||||||
%h2= t(".prompt.header")
|
.card-body
|
||||||
%p= t(".prompt.body")
|
%h2= t(".prompt.header")
|
||||||
%p
|
%p= t(".prompt.body")
|
||||||
%a.btn.btn-primary.btn-lg{ href: url_for(new_user_registration_path) }
|
%p
|
||||||
= t(".register")
|
%a.btn.btn-primary.btn-lg{ href: url_for(new_user_registration_path) }
|
||||||
|
= t(".register")
|
||||||
|
|
||||||
= render "shared/links"
|
= render "shared/links"
|
||||||
|
|
|
@ -40,24 +40,29 @@
|
||||||
%input{ name: "qb-to", type: "hidden", value: user.id }/
|
%input{ name: "qb-to", type: "hidden", value: user.id }/
|
||||||
%button.btn.btn-primary{ name: "qb-ask",
|
%button.btn.btn-primary{ name: "qb-ask",
|
||||||
type: :button,
|
type: :button,
|
||||||
data: { loading_text: t(".load"), promote: user_signed_in? ? "false" : "true", "character-count-target": "action" } }
|
data: { loading_text: t(".load"), promote: user_signed_in? || !user_signed_in? && !APP_CONFIG.dig(:features, :registration, :enabled) ? "false" : "true", "character-count-target": "action" } }
|
||||||
Ask
|
Ask
|
||||||
- unless user_signed_in?
|
- unless user_signed_in?
|
||||||
- if user.privacy_allow_anonymous_questions?
|
- if user.privacy_allow_anonymous_questions?
|
||||||
.d-none#question-box-promote
|
- if APP_CONFIG.dig(:features, :registration, :enabled)
|
||||||
.row
|
.d-none#question-box-promote
|
||||||
.col-12.text-center
|
.row
|
||||||
%strong= t(".promote.message")
|
.col-12.text-center
|
||||||
.row
|
%strong= t(".promote.message")
|
||||||
.col-sm-5.offset-sm-1
|
.row
|
||||||
.d-grid
|
.col-sm-5.offset-sm-1
|
||||||
%button.btn.btn-primary#create-account= t(".promote.create")
|
.d-grid
|
||||||
.col-sm-5
|
%button.btn.btn-primary#create-account= t(".promote.create")
|
||||||
.d-grid
|
.col-sm-5
|
||||||
%button.btn.btn-default#new-question= t(".promote.another")
|
.d-grid
|
||||||
.row
|
%button.btn.btn-default#new-question= t(".promote.another")
|
||||||
.col-xs-12.col-sm-10.offset-sm-1.text-center
|
.row
|
||||||
%small= t(".promote.join", app_title: APP_CONFIG["site_name"])
|
.col-xs-12.col-sm-10.offset-sm-1.text-center
|
||||||
|
%small= t(".promote.join", app_title: APP_CONFIG["site_name"])
|
||||||
- else
|
- else
|
||||||
.text-center
|
.text-center
|
||||||
%strong= t(".status.non_anonymous_html", sign_in: link_to(t("voc.login"), new_user_session_path), sign_up: link_to(t("voc.register"), new_user_registration_path))
|
- if APP_CONFIG.dig(:features, :registration, :enabled)
|
||||||
|
%strong= t(".status.non_anonymous_html", sign_in: link_to(t("voc.login"), new_user_session_path), sign_up: link_to(t("voc.register"), new_user_registration_path))
|
||||||
|
- else
|
||||||
|
%strong= t(".status.non_anonymous_no_registration_html", sign_in: link_to(t("voc.login"), new_user_session_path))
|
||||||
|
|
||||||
|
|
|
@ -14,4 +14,5 @@
|
||||||
.collapse.navbar-collapse#j2-main-navbar-collapse
|
.collapse.navbar-collapse#j2-main-navbar-collapse
|
||||||
%ul.nav.navbar-nav.ms-auto
|
%ul.nav.navbar-nav.ms-auto
|
||||||
= nav_entry t("voc.login"), new_user_session_path
|
= nav_entry t("voc.login"), new_user_session_path
|
||||||
= nav_entry t("voc.register"), new_user_registration_path
|
- if APP_CONFIG.dig(:features, :registration, :enabled)
|
||||||
|
= nav_entry t("voc.register"), new_user_registration_path
|
||||||
|
|
|
@ -52,6 +52,9 @@ features:
|
||||||
# Public timeline
|
# Public timeline
|
||||||
public:
|
public:
|
||||||
enabled: true
|
enabled: true
|
||||||
|
# Registrations
|
||||||
|
registration:
|
||||||
|
enabled: true
|
||||||
|
|
||||||
# Redis
|
# Redis
|
||||||
redis_url: "redis://localhost:6379"
|
redis_url: "redis://localhost:6379"
|
||||||
|
|
|
@ -146,6 +146,9 @@ en:
|
||||||
non_anonymous_html: |
|
non_anonymous_html: |
|
||||||
This user does not want to receive anonymous questions. <br/>
|
This user does not want to receive anonymous questions. <br/>
|
||||||
(%{sign_in} or %{sign_up})
|
(%{sign_in} or %{sign_up})
|
||||||
|
non_anonymous_no_registration_html: |
|
||||||
|
This user does not want to receive anonymous questions. <br/>
|
||||||
|
(%{sign_in})
|
||||||
comment:
|
comment:
|
||||||
show_reactions:
|
show_reactions:
|
||||||
title: "People who smiled this comment"
|
title: "People who smiled this comment"
|
||||||
|
|
|
@ -63,7 +63,7 @@ Rails.application.routes.draw do
|
||||||
# :registrations
|
# :registrations
|
||||||
get "settings/delete_account" => "devise/registrations#cancel", :as => :cancel_user_registration
|
get "settings/delete_account" => "devise/registrations#cancel", :as => :cancel_user_registration
|
||||||
post "/user/create" => "user/registrations#create", :as => :user_registration
|
post "/user/create" => "user/registrations#create", :as => :user_registration
|
||||||
get "/sign_up" => "devise/registrations#new", :as => :new_user_registration
|
get "/sign_up" => "user/registrations#new", :as => :new_user_registration
|
||||||
get "/settings/account" => "devise/registrations#edit", :as => :edit_user_registration
|
get "/settings/account" => "devise/registrations#edit", :as => :edit_user_registration
|
||||||
patch "/settings/account" => "devise/registrations#update", :as => :update_user_registration
|
patch "/settings/account" => "devise/registrations#update", :as => :update_user_registration
|
||||||
put "/settings/account" => "devise/registrations#update"
|
put "/settings/account" => "devise/registrations#update"
|
||||||
|
|
Loading…
Reference in a new issue