devise_token_auth
devise_token_auth copied to clipboard
Email can't be blank. How to create a user with blank email?
I can't create the user if the email is nil or blank even the email field is not a required field in the database.
Bit if I remove include DeviseTokenAuth::Concerns::User
from the user model I can create with a blank email.
- Version: 1.1.5
- Rails Stacktrace:
2.7.2 :004 > User.create!(first_name: 'a', last_name: 'b', password: '1234qwer', password_confirmation: '1234qwer')
TRANSACTION (0.9ms) BEGIN
User Exists? (1.7ms) SELECT 1 AS one FROM "users" WHERE "users"."email" IS NULL AND "users"."provider" = $1 LIMIT $2 [["provider", "email"], ["LIMIT", 1]]
TRANSACTION (0.4ms) ROLLBACK
Traceback (most recent call last):
2: from (irb):3
1: from (irb):4:in `rescue in irb_binding'
ActiveRecord::RecordInvalid (Validation failed: Email can't be blank)
A few validations are added by default here
There is a default_callbacks
options you can disable to prevent the inclusion of DeviseTokenAuth::Concerns::UserOmniauthCallbacks
concern
Just make sure you know what you're doing, you will not only lose validations but everything inside that concern
You can find the config option in here
In your devise_toke_auth.rb
file:
DeviseTokenAuth.setup do |config|
...
# By default we will use callbacks for single omniauth.
# It depends on fields like email, provider and uid.
config.default_callbacks = false
end