Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
webui: allow to set the cookie expiration time, fixes #3032
  • Loading branch information
perexg committed Sep 21, 2015
1 parent 984fbdc commit 39350f1
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 8 deletions.
8 changes: 8 additions & 0 deletions src/config.c
Expand Up @@ -1545,6 +1545,7 @@ config_boot ( const char *path, gid_t gid, uid_t uid )
memset(&config, 0, sizeof(config));
config.idnode.in_class = &config_class;
config.info_area = strdup("login,storage,time");
config.cookie_expires = 7;

/* Generate default */
if (!path) {
Expand Down Expand Up @@ -1832,6 +1833,13 @@ const idclass_t config_class = {
.off = offsetof(config_t, server_name),
.group = 1
},
{
.type = PT_U32,
.id = "cookie_expires",
.name = N_("Cookie expiration (days)"),
.off = offsetof(config_t, cookie_expires),
.group = 1
},
{
.type = PT_STR,
.id = "cors_origin",
Expand Down
1 change: 1 addition & 0 deletions src/config.h
Expand Up @@ -42,6 +42,7 @@ typedef struct config {
int tvhtime_ntp_enabled;
uint32_t tvhtime_tolerance;
char *cors_origin;
uint32_t cookie_expires;
} config_t;

extern const idclass_t config_class;
Expand Down
3 changes: 3 additions & 0 deletions src/webui/comet.c
Expand Up @@ -158,6 +158,9 @@ comet_access_update(http_connection_t *hc, comet_mailbox_t *cmb)

htsmsg_add_s64(m, "time", time(NULL));

if (config.cookie_expires)
htsmsg_add_u32(m, "cookie_expires", config.cookie_expires);

if (config.info_area && config.info_area[0])
htsmsg_add_str(m, "info_area", config.info_area);

Expand Down
22 changes: 14 additions & 8 deletions src/webui/static/app/tvheadend.js
Expand Up @@ -2,11 +2,13 @@ tvheadend.dynamic = true;
tvheadend.accessupdate = null;
tvheadend.capabilities = null;

tvheadend.cookieProvider = new Ext.state.CookieProvider({
// 7 days from now
expires: new Date(new Date().getTime() + (1000 * 60 * 60 * 24 * 7))
});

/* State Provider */
Ext.state.Manager.setProvider(new Ext.state.CookieProvider({
// 7 days from now
expires: new Date(new Date().getTime() + (1000 * 60 * 60 * 24 * 7))
}));
Ext.state.Manager.setProvider(tvheadend.cookieProvider);

tvheadend.regexEscape = function(s) {
return s.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
Expand Down Expand Up @@ -350,13 +352,17 @@ function accessUpdate(o) {
return;

if ('info_area' in o)
tvheadend.rootTabPanel.setInfoArea(o.info_area);
tvheadend.rootTabPanel.setInfoArea(o.info_area);
if ('username' in o)
tvheadend.rootTabPanel.setLogin(o.username);
tvheadend.rootTabPanel.setLogin(o.username);
if ('address' in o)
tvheadend.rootTabPanel.setAddress(o.address);
tvheadend.rootTabPanel.setAddress(o.address);
if ('freediskspace' in o && 'totaldiskspace' in o)
tvheadend.rootTabPanel.setDiskSpace(o.freediskspace, o.totaldiskspace);
tvheadend.rootTabPanel.setDiskSpace(o.freediskspace, o.totaldiskspace);

if ('cookie_expires' in o && o.cookie_expires > 0)
tvheadend.cookieProvider.expires =
new Date(new Date().getTime() + (1000 * 60 * 60 * 24 * o.cookie_expires));

if (tvheadend.autorecButton)
tvheadend.autorecButton.setDisabled(o.dvr != true);
Expand Down

0 comments on commit 39350f1

Please sign in to comment.