mirror of
https://github.com/heartcombo/devise.git
synced 2026-01-09 14:58:05 -05:00
Fix missing validations on Signup (#4674)
* Fix missing validations on Signup This commit fixes issue https://github.com/plataformatec/devise/issues/4673 This removes `validate: false` from saving a record when `Trackable` is in use. * Add test case * Add mongoid model
This commit is contained in:
committed by
Leonardo Tegon
parent
ce0414271a
commit
31801fc9a0
@@ -4,4 +4,6 @@ class User < ActiveRecord::Base
|
||||
include Shim
|
||||
include SharedUser
|
||||
include ActiveModel::Serializers::Xml if Devise::Test.rails5?
|
||||
|
||||
validates :sign_in_count, presence: true
|
||||
end
|
||||
|
||||
10
test/rails_app/app/active_record/user_with_validations.rb
Normal file
10
test/rails_app/app/active_record/user_with_validations.rb
Normal file
@@ -0,0 +1,10 @@
|
||||
require 'shared_user'
|
||||
|
||||
class UserWithValidations < ActiveRecord::Base
|
||||
self.table_name = 'users'
|
||||
include Shim
|
||||
include SharedUser
|
||||
|
||||
validates :email, presence: true
|
||||
end
|
||||
|
||||
35
test/rails_app/app/mongoid/user_with_validations.rb
Normal file
35
test/rails_app/app/mongoid/user_with_validations.rb
Normal file
@@ -0,0 +1,35 @@
|
||||
require "shared_user"
|
||||
|
||||
class UserWithValidations
|
||||
include Mongoid::Document
|
||||
include Shim
|
||||
include SharedUser
|
||||
|
||||
field :username, type: String
|
||||
field :facebook_token, type: String
|
||||
|
||||
## Database authenticatable
|
||||
field :email, type: String, default: ""
|
||||
field :encrypted_password, type: String, default: ""
|
||||
|
||||
## Recoverable
|
||||
field :reset_password_token, type: String
|
||||
field :reset_password_sent_at, type: Time
|
||||
|
||||
## Rememberable
|
||||
field :remember_created_at, type: Time
|
||||
|
||||
## Trackable
|
||||
field :sign_in_count, type: Integer, default: 0
|
||||
field :current_sign_in_at, type: Time
|
||||
field :last_sign_in_at, type: Time
|
||||
field :current_sign_in_ip, type: String
|
||||
field :last_sign_in_ip, type: String
|
||||
|
||||
## Lockable
|
||||
field :failed_attempts, type: Integer, default: 0 # Only if lock strategy is :failed_attempts
|
||||
field :unlock_token, type: String # Only if unlock strategy is :email or :both
|
||||
field :locked_at, type: Time
|
||||
|
||||
validates :email, presence: true
|
||||
end
|
||||
Reference in New Issue
Block a user