diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 41b683a37..10a5efc0d 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -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: diff --git a/lib/notification_factory.rb b/lib/notification_factory.rb index 28be0c5b3..79f339e00 100644 --- a/lib/notification_factory.rb +++ b/lib/notification_factory.rb @@ -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,