Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Registration Without E-Mail #4811

Merged
merged 1 commit into from
Jun 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/controllers/users/registrations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ def new

def create
build_resource(sign_up_params)
resource.registering_from_web = true

if resource.valid?
super
else
Expand Down
3 changes: 2 additions & 1 deletion app/models/user.rb
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -333,7 +334,7 @@ def username_required?
end

def email_required?
!erased? && unverified?
!erased? && (unverified? || registering_from_web)
end

def locale
Expand Down
15 changes: 15 additions & 0 deletions spec/system/registration_form_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,21 @@
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")

Expand Down