@@ -78,6 +78,17 @@ function _M:getExpiresIn(expire_at)
7878 return expires_in_s
7979end
8080
81+ function _M :getContextPropertiesObject (obj )
82+ local props = {}
83+ for k , v in pairs (obj ) do
84+ props [k ] = v
85+ if k == " user_name" or k == " user_first_name" or k == " user_last_name" then
86+ props [k ] = ngx .escape_uri (v )
87+ end
88+ end
89+ return props
90+ end
91+
8192function _M :getProfileFromCache (cacheLookupKey )
8293 local localCacheValue = self :getKeyFromLocalCache (cacheLookupKey , " cachedUserProfiles" )
8394 if ( localCacheValue ~= nil ) then
@@ -148,7 +159,8 @@ function _M:extractContextVars(profile)
148159 cachingObj .user_country_code = profile .countryCode
149160 cachingObj .user_name = profile .displayName
150161 cachingObj .user_region = self :getUserRegion (profile .countryCode )
151-
162+ cachingObj .user_first_name = profile .first_name
163+ cachingObj .user_last_name = profile .last_name
152164 return cachingObj
153165end
154166
@@ -169,7 +181,7 @@ function _M:validateRequest()
169181 if (type (cachedUserProfile ) == ' string' ) then
170182 cachedUserProfile = cjson .decode (cachedUserProfile )
171183 end
172- self :setContextProperties (cachedUserProfile )
184+ self :setContextProperties (self : getContextPropertiesObject ( cachedUserProfile ) )
173185 if ( self :isProfileValid (cachedUserProfile ) == true ) then
174186 return self :exitFn (ngx .HTTP_OK )
175187 else
@@ -185,7 +197,7 @@ function _M:validateRequest()
185197
186198 local cachingObj = self :extractContextVars (json )
187199
188- self :setContextProperties (cachingObj )
200+ self :setContextProperties (self : getContextPropertiesObject ( cachingObj ) )
189201 self :storeProfileInCache (cacheLookupKey , cachingObj )
190202
191203 if ( self :isProfileValid (cachingObj ) == true ) then
0 commit comments