Sign up for new account via invitation #9

Merged
raucao merged 20 commits from feature/signup_from_invite into master 2020-12-04 12:30:28 +00:00
2 changed files with 19 additions and 1 deletions
Showing only changes of commit 2a2b0a90dc - Show all commits

View File

@ -0,0 +1,15 @@
require 'mail'
module EmailValidatable
extend ActiveSupport::Concern
class EmailValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
begin
a = Mail::Address.new(value)
rescue Mail::Field::ParseError
record.errors[attribute] << (options[:message] || "is not a valid address")
end
end
end
end

View File

@ -1,10 +1,13 @@
class User < ApplicationRecord
include EmailValidatable
# Relations
has_many :invitations, dependent: :destroy
validates_uniqueness_of :cn
validates_uniqueness_of :email
validates_length_of :cn, :minimum => 3
validates_uniqueness_of :email
validates :email, email: true
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable