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

Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
This commit is contained in:
Dmitriy Zaporozhets 2013-12-26 10:20:36 +02:00
parent a389d77769
commit 4cd7a56333
No known key found for this signature in database
GPG key ID: 627C5F589F467F17
3 changed files with 12 additions and 2 deletions

View file

@ -47,7 +47,7 @@ class Admin::UsersController < Admin::ApplicationController
@user.admin = (admin && admin.to_i > 0)
@user.created_by_id = current_user.id
@user.generate_password
@user.confirm!
@user.skip_confirmation!
respond_to do |format|
if @user.save

View file

@ -103,7 +103,7 @@ class User < ActiveRecord::Base
# Validations
#
validates :name, presence: true
validates :email, presence: true, format: { with: /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/ }
validates :email, presence: true, format: { with: /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/ }, uniqueness: true
validates :bio, length: { maximum: 255 }, allow_blank: true
validates :extern_uid, allow_blank: true, uniqueness: {scope: :provider}
validates :projects_limit, presence: true, numericality: {greater_than_or_equal_to: 0}

View file

@ -43,6 +43,16 @@
%span.light Member since:
%strong
= @user.created_at.stamp("Nov 12, 2031")
- if @user.confirmed_at
%li
%span.light Confirmed at:
%strong
= @user.confirmed_at.stamp("Nov 12, 2031")
- else
%li
%span.light Confirmed:
%strong.cred
No
%li
%span.light Last sign-in at: