]> git.openstreetmap.org Git - rails.git/blobdiff - app/models/user.rb
Convert the search forms to bootstrap
[rails.git] / app / models / user.rb
index 65c70d2c7a4f8e097ae1277a1e4835a8ab032d1c..42fa40e538da528c8149c8bedcfa6f7504adab2a 100644 (file)
@@ -44,6 +44,7 @@
 #
 
 class User < ApplicationRecord
+  require "digest"
   require "xml/libxml"
 
   has_many :traces, -> { where(:visible => true) }
@@ -103,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? }
@@ -152,26 +155,6 @@ class User < ApplicationRecord
     user
   end
 
-  def to_xml
-    doc = OSM::API.new.get_xml_doc
-    doc.root << to_xml_node
-    doc
-  end
-
-  def to_xml_node
-    el1 = XML::Node.new "user"
-    el1["display_name"] = display_name.to_s
-    el1["account_created"] = creation_time.xmlschema
-    if home_lat && home_lon
-      home = XML::Node.new "home"
-      home["lat"] = home_lat.to_s
-      home["lon"] = home_lon.to_s
-      home["zoom"] = home_zoom.to_s
-      el1 << home
-    end
-    el1
-  end
-
   def description
     RichText.new(self[:description_format], self[:description])
   end
@@ -306,6 +289,13 @@ class User < ApplicationRecord
     ClientApplication.find_by(:key => application_key).access_token_for_user(self)
   end
 
+  def fingerprint
+    digest = Digest::SHA256.new
+    digest.update(email)
+    digest.update(pass_crypt)
+    digest.hexdigest
+  end
+
   private
 
   def set_defaults