]> git.openstreetmap.org Git - rails.git/blobdiff - app/models/user.rb
Use rails tokens for email changes
[rails.git] / app / models / user.rb
index 7faf748cd8afdb5866af50915e8dcd033a8dd2c2..958a03a9821220c3e4512b8b20d1352208e5fef1 100644 (file)
@@ -124,6 +124,14 @@ class User < ApplicationRecord
   before_save :update_tile
   after_save :spam_check
 
   before_save :update_tile
   after_save :spam_check
 
+  generates_token_for :new_email, :expires_in => 1.week do
+    fingerprint
+  end
+
+  generates_token_for :password_reset, :expires_in => 1.week do
+    fingerprint
+  end
+
   def display_name_cannot_be_user_id_with_other_id
     display_name&.match(/^user_(\d+)$/i) do |m|
       errors.add :display_name, I18n.t("activerecord.errors.messages.display_name_is_user_n") unless m[1].to_i == id
   def display_name_cannot_be_user_id_with_other_id
     display_name&.match(/^user_(\d+)$/i) do |m|
       errors.add :display_name, I18n.t("activerecord.errors.messages.display_name_is_user_n") unless m[1].to_i == id