summaryrefslogtreecommitdiff
path: root/app/models/user.rb
diff options
context:
space:
mode:
authorDouwe Maan <douwe@selenight.nl>2016-08-19 18:33:46 -0500
committertiagonbotelho <tiagonbotelho@hotmail.com>2016-11-07 15:55:42 +0000
commit9d51421346178c9189ffb47189f51d573ab42822 (patch)
tree4990e9766af58e9dfc687f5451c6efe36fdbebcd /app/models/user.rb
parent09f4af04c6672f7e2d1584f9940a3d9ff53a4a4f (diff)
downloadgitlab-ce-9d51421346178c9189ffb47189f51d573ab42822.tar.gz
Use separate email-friendly token for incoming email and let incoming
email token be reset
Diffstat (limited to 'app/models/user.rb')
-rw-r--r--app/models/user.rb12
1 files changed, 11 insertions, 1 deletions
diff --git a/app/models/user.rb b/app/models/user.rb
index 65e96ee6b2e..9a3619b0bc3 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -13,6 +13,7 @@ class User < ActiveRecord::Base
DEFAULT_NOTIFICATION_LEVEL = :participating
add_authentication_token_field :authentication_token
+ add_authentication_token_field :incoming_email_token
default_value_for :admin, false
default_value_for(:external) { current_application_settings.user_default_external }
@@ -119,7 +120,7 @@ class User < ActiveRecord::Base
before_validation :set_public_email, if: ->(user) { user.public_email_changed? }
after_update :update_emails_with_primary_email, if: ->(user) { user.email_changed? }
- before_save :ensure_authentication_token
+ before_save :ensure_authentication_token, :ensure_incoming_email_token
before_save :ensure_external_user_rights
after_save :ensure_namespace_correct
after_initialize :set_projects_limit
@@ -946,4 +947,13 @@ class User < ActiveRecord::Base
signup_domain =~ regexp
end
end
+
+ def generate_token(token_field)
+ if token_field == :incoming_email_token
+ # Needs to be all lowercase and alphanumeric because it's gonna be used in an email address.
+ SecureRandom.hex
+ else
+ super
+ end
+ end
end