mirror of
https://github.com/we-promise/sure.git
synced 2026-04-19 03:54:08 +00:00
Add onboarding state selector for self-hosted signup (#251)
* Add onboarding modes to self-hosted signup * Style form consistently * Configure ONBOARDING_STATE via ENV
This commit is contained in:
@@ -8,7 +8,11 @@ module Invitable
|
||||
private
|
||||
def invite_code_required?
|
||||
return false if @invitation.present?
|
||||
self_hosted? ? Setting.require_invite_for_signup : ENV["REQUIRE_INVITE_CODE"] == "true"
|
||||
if self_hosted?
|
||||
Setting.onboarding_state == "invite_only"
|
||||
else
|
||||
ENV["REQUIRE_INVITE_CODE"] == "true"
|
||||
end
|
||||
end
|
||||
|
||||
def self_hosted?
|
||||
|
||||
@@ -3,6 +3,7 @@ class RegistrationsController < ApplicationController
|
||||
|
||||
layout "auth"
|
||||
|
||||
before_action :ensure_signup_open, if: :self_hosted?
|
||||
before_action :set_user, only: :create
|
||||
before_action :set_invitation
|
||||
before_action :claim_invite_code, only: :create, if: :invite_code_required?
|
||||
@@ -79,4 +80,10 @@ class RegistrationsController < ApplicationController
|
||||
render :new, status: :unprocessable_entity
|
||||
end
|
||||
end
|
||||
|
||||
def ensure_signup_open
|
||||
return unless Setting.onboarding_state == "closed"
|
||||
|
||||
redirect_to new_session_path, alert: t("registrations.closed")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -15,8 +15,9 @@ class Settings::HostingsController < ApplicationController
|
||||
end
|
||||
|
||||
def update
|
||||
if hosting_params.key?(:require_invite_for_signup)
|
||||
Setting.require_invite_for_signup = hosting_params[:require_invite_for_signup]
|
||||
if hosting_params.key?(:onboarding_state)
|
||||
onboarding_state = hosting_params[:onboarding_state].to_s
|
||||
Setting.onboarding_state = onboarding_state
|
||||
end
|
||||
|
||||
if hosting_params.key?(:require_email_confirmation)
|
||||
@@ -68,7 +69,7 @@ class Settings::HostingsController < ApplicationController
|
||||
|
||||
private
|
||||
def hosting_params
|
||||
params.require(:setting).permit(:require_invite_for_signup, :require_email_confirmation, :brand_fetch_client_id, :twelve_data_api_key, :openai_access_token, :openai_uri_base, :openai_model)
|
||||
params.require(:setting).permit(:onboarding_state, :require_email_confirmation, :brand_fetch_client_id, :twelve_data_api_key, :openai_access_token, :openai_uri_base, :openai_model)
|
||||
end
|
||||
|
||||
def ensure_admin
|
||||
|
||||
Reference in New Issue
Block a user