Fixed login, new_password and invitation views.

This commit is contained in:
benni 2012-10-08 11:51:56 +02:00
parent f20ae890dd
commit 1708df3f6c
18 changed files with 200 additions and 122 deletions

View file

@ -12,20 +12,16 @@ class Invite < ActiveRecord::Base
validates_presence_of :expires_at
validate :email_not_already_registered, :on => :create
before_validation :set_token_and_expires_at
protected
# Before validation, set token and expires_at.
def before_validation
def set_token_and_expires_at
self.token = Digest::SHA1.hexdigest(Time.now.to_s + rand(100).to_s)
self.expires_at = Time.now.advance(:days => 7)
end
# Sends an email to the invited user.
def after_create
Mailer.invite(self).deliver
end
private
# Custom validation: check that email does not already belong to a registered user.