liquid_feedback_frontend

diff app/main/api/profile.lua @ 1817:757a87af4c83

Added validation hook for profile updates
author bsw
date Mon Dec 13 11:57:35 2021 +0100 (2021-12-13)
parents 32cc544d5a5b
children
line diff
     1.1 --- a/app/main/api/profile.lua	Fri Dec 03 10:31:51 2021 +0100
     1.2 +++ b/app/main/api/profile.lua	Mon Dec 13 11:57:35 2021 +0100
     1.3 @@ -17,6 +17,12 @@
     1.4        if value ~= nil and (field.type == "string" or field.type == "text") and json.type(value) ~= "string" then
     1.5          return util.api_error(400, "Bad Request", "string_expected", "JSON encoded string value expected")
     1.6        end
     1.7 +      if field.validate_func then
     1.8 +        local success = field.validate_func(field, fields)
     1.9 +        if not success then
    1.10 +          return util.api_error(403, "Forbidden", "validation_failure", "Request could not be validated")
    1.11 +        end
    1.12 +      end
    1.13        profile.profile[field.id] = value
    1.14      end
    1.15    end

Impressum / About Us