Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Timo Perplex 13 posts 145 karma points c-trib
    Nov 24, 2015 @ 12:23
    Timo Perplex
    0

    Umbraco Forms (v7) - Encrypt and decrypt form variables

    I'm trying to encrypt Umbraco Forms values stored the database, and decrypt them when viewing in the backoffice and exporting.

    The encryption part can take place in the workflow used, but I can't find a location to override or change to decrypt the values.

    This topic shows which steps to take to encrypt and decrypt, but the DataTables_json.xslt doensn`t seem to be used anymore in the V7 version of Umbraco Forms. Does anyone know which logic I need to override / change to get the decryption to work?

    Ps. there also doensn`t seem to be an event to execute after saving the records to the database, only before: RecordStorage.RecordInserting. The after event could be used to always encrypt instead of defined per workflow.

    I tried to update the values in the RecordInserting event, but they don't seem to be used in the save function:

           void RecordStorage_RecordInserting(object sender, Umbraco.Forms.Core.RecordEventArgs e)
        {
            foreach (var record in e.Record.RecordFields)
            {
                record.Value.Values = new List<object>() { Security.Encrypt(record.Value.Values.FirstOrDefault().ToString(), "key") };
            };
        }
    
  • Julian C. 16 posts 73 karma points
    Jan 28, 2016 @ 14:47
    Julian C.
    0

    Maybe too late for you, but I've found how to make this work. After modifying any field values, you have to rebuild the JSON representation of the record data:

    args.Record.RecordData = args.Record.GenerateRecordDataAsJson();
    

    or in your case:

    e.Record.RecordData = e.Record.GenerateRecordDataAsJson();
    
Please Sign in or register to post replies

Write your reply to:

Draft