Fixed user invitation.

This commit is contained in:
Martin Edenhofer 2013-01-03 11:47:39 +01:00
parent a9b1e4c8a5
commit 8965e76360
2 changed files with 12 additions and 6 deletions

View file

@ -157,8 +157,8 @@ curl http://localhost/api/users.json -v -u #{login}:#{password} -H "Content-Type
user.save
# send inviteation if needed
if params[:invite]
# send inviteation if needed / only if session exists
if params[:invite] && current_user
# generate token
token = Token.create( :action => 'PasswordReset', :user_id => user.id )
@ -168,7 +168,7 @@ curl http://localhost/api/users.json -v -u #{login}:#{password} -H "Content-Type
data[:subject] = 'Invitation to #{config.product_name} at #{config.fqdn}'
data[:body] = 'Hi {user.firstname},
I (#{current_user.firstname} #{current_user.lastname}) invite you to #{config.product_name}.
I (#{current_user.firstname} #{current_user.lastname}) invite you to #{config.product_name} - a customer support / ticket system platform.
Click on the following link and set your password:

View file

@ -23,6 +23,7 @@ end
module NotificationFactory
def self.build(data)
data[:string].gsub!( /\#\{(.+?)\}/ ) { |s|
# use quoted text
@ -44,14 +45,19 @@ module NotificationFactory
replace = nil
if data[:objects][object_name.to_sym]
replace = "data[:objects]['#{object_name}'.to_sym]#{object_method}"
else
else
replace = $1 + $2
end
item = replace
}
# replace value
s = eval callback
begin
s = eval callback
rescue Exception => e
Rails.logger.error "can't eval #{callback}"
Rails.logger.error e.inspect
end
}
return data[:string]
end
@ -59,7 +65,7 @@ module NotificationFactory
def self.send(data)
sender = Setting.get('notification_sender')
a = Channel::IMAP.new
puts "NOTICE: SEND NOTIFICATION TO: #{data[:recipient][:email]}"
Rails.logger.info "NOTICE: SEND NOTIFICATION TO: #{data[:recipient][:email]}"
message = a.send(
{
# :in_reply_to => self.in_reply_to,