Allow sign up without email smtp config (#13650)
This commit is contained in:
parent
b25965a779
commit
5b8b651b67
5 changed files with 16 additions and 2 deletions
|
|
@ -31,7 +31,12 @@ class RegistrationsController < Devise::RegistrationsController
|
|||
yield resource if block_given?
|
||||
if resource.persisted?
|
||||
update_first_user_permissions(resource)
|
||||
redirect_to "/confirm-email?email=#{CGI.escape(resource.email)}"
|
||||
if SiteConfig.smtp_enabled?
|
||||
redirect_to confirm_email_path(email: resource.email)
|
||||
else
|
||||
sign_in(resource)
|
||||
redirect_to root_path
|
||||
end
|
||||
else
|
||||
render action: "by_email"
|
||||
end
|
||||
|
|
|
|||
|
|
@ -224,4 +224,8 @@ class SiteConfig < RailsSettings::Base
|
|||
def self.get_default(field)
|
||||
get_field(field)[:default]
|
||||
end
|
||||
|
||||
def self.smtp_enabled?
|
||||
Rails.configuration.action_mailer.perform_deliveries
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -694,4 +694,8 @@ class User < ApplicationRecord
|
|||
def strip_payment_pointer
|
||||
self.payment_pointer = payment_pointer.strip if payment_pointer
|
||||
end
|
||||
|
||||
def confirmation_required?
|
||||
SiteConfig.smtp_enabled?
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -127,7 +127,7 @@ Rails.application.configure do
|
|||
protocol = ENV["APP_PROTOCOL"] || "http://"
|
||||
|
||||
config.action_mailer.delivery_method = :smtp
|
||||
config.action_mailer.perform_deliveries = true
|
||||
config.action_mailer.perform_deliveries = ENV["SMTP_PASWORD"].present? || ENV["SENDGRID_API_KEY"].present?
|
||||
config.action_mailer.default_url_options = { host: protocol + ENV["APP_DOMAIN"].to_s }
|
||||
ActionMailer::Base.smtp_settings = if ENV["SENDGRID_API_KEY"].present?
|
||||
{
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ RSpec.describe "Authenticating with Email" do
|
|||
before do
|
||||
allow(Settings::Authentication).to receive(:allow_email_password_registration).and_return(true)
|
||||
allow(Settings::Authentication).to receive(:allow_email_password_login).and_return(true)
|
||||
allow(SiteConfig).to receive(:smtp_enabled?).and_return(true)
|
||||
# rubocop:disable RSpec/AnyInstance
|
||||
allow_any_instance_of(ProfileImageUploader).to receive(:download!)
|
||||
# rubocop:enable RSpec/AnyInstance
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue