add missing username for blog notifications (#5422)

The notifications backend it worked fine, but the frontend was missing the username variable to be in able to display the 'New' badge correctly
This commit is contained in:
gabryon99 2021-05-31 10:25:40 +02:00
parent 7d51eb47f7
commit 24f054f009
6 changed files with 39 additions and 35 deletions

View file

@ -187,9 +187,6 @@ local message_enabled = (areHostL7TimeseriesEnabled(ifid) or areHostCategoriesTi
if not info.oem then
-- Create a CSRF Token to handle the blog notifications
print([[
<script type='text/javascript'>
const blogNotificationCsrf = "]].. ntop.getRandomCSRFValue() ..[[";
</script>
<script type='text/javascript' src=']].. ntop.getHttpPrefix() ..[[/js/utils/blog-notification-utils.js?]].. ntop.getStaticFileEpoch() ..[['></script>
]])
end

View file

@ -82,10 +82,14 @@ print[[
window.unchangable_pool_names = [
'Jailed hosts pool'
]
window.__IS_PRO__ = ]] print(ntop.isPro()) print[[;
window.__CSRF_DATATABLE__ = `]] print(ntop.getRandomCSRFValue()) print[[`;
window.__BLOG_NOTIFICATION_CSRF__ = `]] print(ntop.getRandomCSRFValue()) print[[`;
if(document.cookie.indexOf("tzoffset=") < 0) {
if (document.cookie.indexOf("tzoffset=") < 0) {
// Tell the server the client timezone
document.cookie = "tzoffset=" + (new Date().getTimezoneOffset() * 60 * -1);
}
@ -1070,7 +1074,8 @@ if (not info.oem) then
local posts, new_posts_counter = blog_utils.readPostsFromRedis(username)
template_utils.render("pages/components/blog-dropdown.template", {
posts = posts,
new_posts_counter = new_posts_counter
new_posts_counter = new_posts_counter,
username = username
})
end