forked from e621ng/e621ng
prevent the creation of users with empty string email addresses
This commit is contained in:
parent
b92c312605
commit
72bfac3d90
@ -24,6 +24,7 @@ class User < ActiveRecord::Base
|
||||
validates_confirmation_of :password
|
||||
validates_presence_of :email, :if => lambda {|rec| rec.new_record? && Danbooru.config.enable_email_verification?}
|
||||
validate :validate_ip_addr_is_not_banned, :on => :create
|
||||
before_validation :convert_blank_email_to_null
|
||||
before_save :encrypt_password
|
||||
after_save :update_cache
|
||||
before_create :promote_to_admin_if_first_user
|
||||
@ -218,7 +219,7 @@ class User < ActiveRecord::Base
|
||||
end
|
||||
end
|
||||
|
||||
module EmailVerificationMethods
|
||||
module EmailMethods
|
||||
def is_verified?
|
||||
email_verification_key.blank?
|
||||
end
|
||||
@ -234,6 +235,12 @@ class User < ActiveRecord::Base
|
||||
raise User::Error.new("Verification key does not match")
|
||||
end
|
||||
end
|
||||
|
||||
def convert_blank_email_to_null
|
||||
if email.blank?
|
||||
self.email = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
module BlacklistMethods
|
||||
@ -332,7 +339,7 @@ class User < ActiveRecord::Base
|
||||
extend AuthenticationMethods
|
||||
include FavoriteMethods
|
||||
include LevelMethods
|
||||
include EmailVerificationMethods
|
||||
include EmailMethods
|
||||
include BlacklistMethods
|
||||
include ForumMethods
|
||||
include LimitMethods
|
||||
|
10
db/seeds.rb
10
db/seeds.rb
@ -45,7 +45,7 @@ end
|
||||
if Comment.count == 0
|
||||
puts "Creating comments"
|
||||
Post.all.each do |post|
|
||||
20.times do
|
||||
rand(30).times do
|
||||
Comment.create(:post_id => post.id, :body => rand(1_000_000).to_s)
|
||||
end
|
||||
end
|
||||
@ -56,8 +56,12 @@ end
|
||||
if Note.count == 0
|
||||
puts "Creating notes"
|
||||
Post.all.each do |post|
|
||||
3.times do
|
||||
Note.create(:post_id => post.id, :x => 0, :y => 0, :width => 100, :height => 100, :body => rand(1_000_000).to_s)
|
||||
rand(10).times do
|
||||
note = Note.create(:post_id => post.id, :x => 0, :y => 0, :width => 100, :height => 100, :body => rand(1_000_000).to_s)
|
||||
|
||||
rand(30).times do |i|
|
||||
note.update_attributes(:body => (i * i).to_s)
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user