Fixed user invitation.
This commit is contained in:
parent
a9b1e4c8a5
commit
8965e76360
|
@ -157,8 +157,8 @@ curl http://localhost/api/users.json -v -u #{login}:#{password} -H "Content-Type
|
||||||
|
|
||||||
user.save
|
user.save
|
||||||
|
|
||||||
# send inviteation if needed
|
# send inviteation if needed / only if session exists
|
||||||
if params[:invite]
|
if params[:invite] && current_user
|
||||||
|
|
||||||
# generate token
|
# generate token
|
||||||
token = Token.create( :action => 'PasswordReset', :user_id => user.id )
|
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[:subject] = 'Invitation to #{config.product_name} at #{config.fqdn}'
|
||||||
data[:body] = 'Hi {user.firstname},
|
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:
|
Click on the following link and set your password:
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@ end
|
||||||
|
|
||||||
module NotificationFactory
|
module NotificationFactory
|
||||||
def self.build(data)
|
def self.build(data)
|
||||||
|
|
||||||
data[:string].gsub!( /\#\{(.+?)\}/ ) { |s|
|
data[:string].gsub!( /\#\{(.+?)\}/ ) { |s|
|
||||||
|
|
||||||
# use quoted text
|
# use quoted text
|
||||||
|
@ -51,7 +52,12 @@ module NotificationFactory
|
||||||
}
|
}
|
||||||
|
|
||||||
# replace value
|
# replace value
|
||||||
|
begin
|
||||||
s = eval callback
|
s = eval callback
|
||||||
|
rescue Exception => e
|
||||||
|
Rails.logger.error "can't eval #{callback}"
|
||||||
|
Rails.logger.error e.inspect
|
||||||
|
end
|
||||||
}
|
}
|
||||||
return data[:string]
|
return data[:string]
|
||||||
end
|
end
|
||||||
|
@ -59,7 +65,7 @@ module NotificationFactory
|
||||||
def self.send(data)
|
def self.send(data)
|
||||||
sender = Setting.get('notification_sender')
|
sender = Setting.get('notification_sender')
|
||||||
a = Channel::IMAP.new
|
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(
|
message = a.send(
|
||||||
{
|
{
|
||||||
# :in_reply_to => self.in_reply_to,
|
# :in_reply_to => self.in_reply_to,
|
||||||
|
|
Loading…
Reference in a new issue