Maintenance: Increase performance of ticket creation via form.

This commit is contained in:
Dominik Klein 2021-09-01 09:46:00 +02:00 committed by Thorsten Eckel
parent b125b3603e
commit f67cf3ab1e

View file

@ -156,7 +156,7 @@ class FormController < ApplicationController
end end
def token_gen(fingerprint) def token_gen(fingerprint)
crypt = ActiveSupport::MessageEncryptor.new(Setting.get('application_secret')[0, 32]) crypt = ActiveSupport::MessageEncryptor.new(Setting.get('application_secret')[0, 32], serializer: JSON)
fingerprint = "#{Base64.strict_encode64(Setting.get('fqdn'))}:#{Time.zone.now.to_i}:#{Base64.strict_encode64(fingerprint)}" fingerprint = "#{Base64.strict_encode64(Setting.get('fqdn'))}:#{Time.zone.now.to_i}:#{Base64.strict_encode64(fingerprint)}"
Base64.strict_encode64(crypt.encrypt_and_sign(fingerprint)) Base64.strict_encode64(crypt.encrypt_and_sign(fingerprint))
end end
@ -167,7 +167,7 @@ class FormController < ApplicationController
raise Exceptions::Forbidden raise Exceptions::Forbidden
end end
begin begin
crypt = ActiveSupport::MessageEncryptor.new(Setting.get('application_secret')[0, 32]) crypt = ActiveSupport::MessageEncryptor.new(Setting.get('application_secret')[0, 32], serializer: JSON)
result = crypt.decrypt_and_verify(Base64.decode64(token)) result = crypt.decrypt_and_verify(Base64.decode64(token))
rescue rescue
Rails.logger.info 'Invalid token for form!' Rails.logger.info 'Invalid token for form!'