18803: Save empty identity_url to database as null.
[arvados.git] / services / api / app / models / user.rb
index febb8ea51611eb5a21549b8133770fe059a2ca5c..811cd89758d9ef8642be5382c9bac54b4f649134 100644 (file)
@@ -21,6 +21,7 @@ class User < ArvadosModel
             uniqueness: true,
             allow_nil: true)
   validate :must_unsetup_to_deactivate
+  validate :identity_url_nil_if_empty
   before_update :prevent_privilege_escalation
   before_update :prevent_inactive_admin
   before_update :verify_repositories_empty, :if => Proc.new {
@@ -810,4 +811,10 @@ SELECT target_uuid, perm_level
       repo.save!
     end
   end
+
+  def identity_url_nil_if_empty
+    if identity_url == ""
+      self.identity_url = nil
+    end
+  end
 end