Merge pull request #4811 from iraline/fix_require_email

Fix Registration Without E-Mail
This commit is contained in:
Sebastia
2022-06-08 13:03:19 +02:00
committed by GitHub
3 changed files with 19 additions and 1 deletions

View File

@@ -12,6 +12,8 @@ class Users::RegistrationsController < Devise::RegistrationsController
def create
build_resource(sign_up_params)
resource.registering_from_web = true
if resource.valid?
super
else

View File

@@ -1,5 +1,6 @@
class User < ApplicationRecord
include Verification
attribute :registering_from_web, default: false
devise :database_authenticatable, :registerable, :confirmable, :recoverable, :rememberable,
:trackable, :validatable, :omniauthable, :password_expirable, :secure_validatable,
@@ -333,7 +334,7 @@ class User < ApplicationRecord
end
def email_required?
!erased? && unverified?
!erased? && (unverified? || registering_from_web)
end
def locale

View File

@@ -23,6 +23,21 @@ describe "Registration form" do
expect(page).to have_content I18n.t("devise_views.users.registrations.new.username_is_available")
end
scenario "do not save blank user_email" do
Setting["feature.user.skip_verification"] = true
visit new_user_registration_path
fill_in "user_username", with: "NewUser"
fill_in "user_password", with: "password"
fill_in "user_password_confirmation", with: "password"
check "user_terms_of_service"
click_button "Register"
expect(page).to have_content "can't be blank"
end
scenario "do not save blank redeemable codes" do
visit new_user_registration_path(use_redeemable_code: "true")