Commit 4cd7a56333138de7438b2b59788f8732222845d7

Authored by Dmitriy Zaporozhets
1 parent a389d777

Add User#email uniq validation. Fixed confirmation for admin/users form

Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
app/controllers/admin/users_controller.rb
@@ -47,7 +47,7 @@ class Admin::UsersController &lt; Admin::ApplicationController @@ -47,7 +47,7 @@ class Admin::UsersController &lt; Admin::ApplicationController
47 @user.admin = (admin && admin.to_i > 0) 47 @user.admin = (admin && admin.to_i > 0)
48 @user.created_by_id = current_user.id 48 @user.created_by_id = current_user.id
49 @user.generate_password 49 @user.generate_password
50 - @user.confirm! 50 + @user.skip_confirmation!
51 51
52 respond_to do |format| 52 respond_to do |format|
53 if @user.save 53 if @user.save
app/models/user.rb
@@ -103,7 +103,7 @@ class User &lt; ActiveRecord::Base @@ -103,7 +103,7 @@ class User &lt; ActiveRecord::Base
103 # Validations 103 # Validations
104 # 104 #
105 validates :name, presence: true 105 validates :name, presence: true
106 - validates :email, presence: true, format: { with: /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/ } 106 + validates :email, presence: true, format: { with: /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/ }, uniqueness: true
107 validates :bio, length: { maximum: 255 }, allow_blank: true 107 validates :bio, length: { maximum: 255 }, allow_blank: true
108 validates :extern_uid, allow_blank: true, uniqueness: {scope: :provider} 108 validates :extern_uid, allow_blank: true, uniqueness: {scope: :provider}
109 validates :projects_limit, presence: true, numericality: {greater_than_or_equal_to: 0} 109 validates :projects_limit, presence: true, numericality: {greater_than_or_equal_to: 0}
app/views/admin/users/show.html.haml
@@ -43,6 +43,16 @@ @@ -43,6 +43,16 @@
43 %span.light Member since: 43 %span.light Member since:
44 %strong 44 %strong
45 = @user.created_at.stamp("Nov 12, 2031") 45 = @user.created_at.stamp("Nov 12, 2031")
  46 + - if @user.confirmed_at
  47 + %li
  48 + %span.light Confirmed at:
  49 + %strong
  50 + = @user.confirmed_at.stamp("Nov 12, 2031")
  51 + - else
  52 + %li
  53 + %span.light Confirmed:
  54 + %strong.cred
  55 + No
46 56
47 %li 57 %li
48 %span.light Last sign-in at: 58 %span.light Last sign-in at: