summaryrefslogtreecommitdiff
path: root/app/models/user.rb
diff options
context:
space:
mode:
authorJohann Pardanaud <pardanaud.j@gmail.com>2016-02-16 19:53:51 +0100
committerJohann Pardanaud <pardanaud.j@gmail.com>2016-02-16 19:53:51 +0100
commitfb6d7df347016726d84155d18b6d6f406d0121e9 (patch)
tree9529bd4b546feeff391ca5a9db0a445f76a9521b /app/models/user.rb
parent78588cfca15348ba062d33061c79df3cfa6b9883 (diff)
parent7cc4b73942a0620678cd7e058d6dcde0ae71f4e6 (diff)
downloadgitlab-ce-fb6d7df347016726d84155d18b6d6f406d0121e9.tar.gz
Merge branch 'master' into avatar-cropping
Conflicts: app/models/user.rb
Diffstat (limited to 'app/models/user.rb')
-rw-r--r--app/models/user.rb16
1 files changed, 6 insertions, 10 deletions
diff --git a/app/models/user.rb b/app/models/user.rb
index a8e602f925a..1b0c82f45c4 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -151,16 +151,8 @@ class User < ActiveRecord::Base
# Validations
#
validates :name, presence: true
-
- [:avatar_crop_x, :avatar_crop_y, :avatar_crop_size].each do |field|
- validates field, numericality: { only_integer: true }, allow_blank: true
- end
-
- # Note that a 'uniqueness' and presence check is provided by devise :validatable for email. We do not need to
- # duplicate that here as the validation framework will have duplicate errors in the event of a failure.
- validates :email, presence: true, email: { strict_mode: true }
- validates :notification_email, presence: true, email: { strict_mode: true }
- validates :public_email, presence: true, email: { strict_mode: true }, allow_blank: true, uniqueness: true
+ validates :notification_email, presence: true, email: true
+ validates :public_email, presence: true, uniqueness: true, email: true, allow_blank: true
validates :bio, length: { maximum: 255 }, allow_blank: true
validates :projects_limit, presence: true, numericality: { greater_than_or_equal_to: 0 }
validates :username,
@@ -176,6 +168,10 @@ class User < ActiveRecord::Base
validate :owns_public_email, if: ->(user) { user.public_email_changed? }
validates :avatar, file_size: { maximum: 200.kilobytes.to_i }
+ [:avatar_crop_x, :avatar_crop_y, :avatar_crop_size].each do |field|
+ validates field, numericality: { only_integer: true }, allow_blank: true
+ end
+
before_validation :generate_password, on: :create
before_validation :restricted_signup_domains, on: :create
before_validation :sanitize_attrs