]> git.openstreetmap.org Git - rails.git/blobdiff - app/models/user.rb
Validate avatar images
[rails.git] / app / models / user.rb
index 9cc8b7d8361cb62a64f7f089a8256d6d6a80ee03..42fa40e538da528c8149c8bedcfa6f7504adab2a 100644 (file)
@@ -104,6 +104,8 @@ class User < ApplicationRecord
   validates :preferred_editor, :inclusion => Editors::ALL_EDITORS, :allow_nil => true
   validates :auth_uid, :unless => proc { |u| u.auth_provider.nil? },
                        :uniqueness => { :scope => :auth_provider }
+  validates :avatar, :if => proc { |u| u.attachment_changes["avatar"] },
+                     :image => true
 
   validates_email_format_of :email, :if => proc { |u| u.email_changed? }
   validates_email_format_of :new_email, :allow_blank => true, :if => proc { |u| u.new_email_changed? }