@@ -78,6 +78,17 @@ function _M:getExpiresIn(expire_at)
78
78
return expires_in_s
79
79
end
80
80
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
+
81
92
function _M :getProfileFromCache (cacheLookupKey )
82
93
local localCacheValue = self :getKeyFromLocalCache (cacheLookupKey , " cachedUserProfiles" )
83
94
if ( localCacheValue ~= nil ) then
@@ -148,7 +159,8 @@ function _M:extractContextVars(profile)
148
159
cachingObj .user_country_code = profile .countryCode
149
160
cachingObj .user_name = profile .displayName
150
161
cachingObj .user_region = self :getUserRegion (profile .countryCode )
151
-
162
+ cachingObj .user_first_name = profile .first_name
163
+ cachingObj .user_last_name = profile .last_name
152
164
return cachingObj
153
165
end
154
166
@@ -169,7 +181,7 @@ function _M:validateRequest()
169
181
if (type (cachedUserProfile ) == ' string' ) then
170
182
cachedUserProfile = cjson .decode (cachedUserProfile )
171
183
end
172
- self :setContextProperties (cachedUserProfile )
184
+ self :setContextProperties (self : getContextPropertiesObject ( cachedUserProfile ) )
173
185
if ( self :isProfileValid (cachedUserProfile ) == true ) then
174
186
return self :exitFn (ngx .HTTP_OK )
175
187
else
@@ -185,7 +197,7 @@ function _M:validateRequest()
185
197
186
198
local cachingObj = self :extractContextVars (json )
187
199
188
- self :setContextProperties (cachingObj )
200
+ self :setContextProperties (self : getContextPropertiesObject ( cachingObj ) )
189
201
self :storeProfileInCache (cacheLookupKey , cachingObj )
190
202
191
203
if ( self :isProfileValid (cachingObj ) == true ) then
0 commit comments