Merge pull request #4811 from iraline/fix_require_email
Fix Registration Without E-Mail
This commit is contained in:
@@ -12,6 +12,8 @@ class Users::RegistrationsController < Devise::RegistrationsController
|
|||||||
|
|
||||||
def create
|
def create
|
||||||
build_resource(sign_up_params)
|
build_resource(sign_up_params)
|
||||||
|
resource.registering_from_web = true
|
||||||
|
|
||||||
if resource.valid?
|
if resource.valid?
|
||||||
super
|
super
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
class User < ApplicationRecord
|
class User < ApplicationRecord
|
||||||
include Verification
|
include Verification
|
||||||
|
attribute :registering_from_web, default: false
|
||||||
|
|
||||||
devise :database_authenticatable, :registerable, :confirmable, :recoverable, :rememberable,
|
devise :database_authenticatable, :registerable, :confirmable, :recoverable, :rememberable,
|
||||||
:trackable, :validatable, :omniauthable, :password_expirable, :secure_validatable,
|
:trackable, :validatable, :omniauthable, :password_expirable, :secure_validatable,
|
||||||
@@ -333,7 +334,7 @@ class User < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
def email_required?
|
def email_required?
|
||||||
!erased? && unverified?
|
!erased? && (unverified? || registering_from_web)
|
||||||
end
|
end
|
||||||
|
|
||||||
def locale
|
def locale
|
||||||
|
|||||||
@@ -23,6 +23,21 @@ describe "Registration form" do
|
|||||||
expect(page).to have_content I18n.t("devise_views.users.registrations.new.username_is_available")
|
expect(page).to have_content I18n.t("devise_views.users.registrations.new.username_is_available")
|
||||||
end
|
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
|
scenario "do not save blank redeemable codes" do
|
||||||
visit new_user_registration_path(use_redeemable_code: "true")
|
visit new_user_registration_path(use_redeemable_code: "true")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user