change hoew viewtokens are aqcuired

This commit is contained in:
Wim Brand
2020-02-21 14:32:06 +01:00
parent 9cfe675d16
commit 1107ecbdad
2 changed files with 8 additions and 11 deletions

View File

@@ -17,15 +17,12 @@ func (wc *WebController) serveAdClick(w http.ResponseWriter, r *http.Request, p
api := pixelapi.New(wc.apiURLInternal)
// Get the view token without authentication
vt := viewTokenOrBust(api)
// Apply authentication and register the view
api.APIKey, _ = wc.getAPIKey(r)
// The Real IP is used in the API server to determine that the view is not
// fake
api.RealIP = util.RemoteAddress(r)
// Log a view on the file
if err := api.PostFileView(p.ByName("id"), vt); err != nil {
if err := api.PostFileView(p.ByName("id"), wc.viewTokenOrBust()); err != nil {
log.Warn("Failed to log view")
}
}