From b1c885a266af0d01747cd9c89e6847e95f0c81d8 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Tue, 2 Apr 2019 11:18:05 -0600 Subject: [PATCH 1/3] Expire mobile guide cookie after 24 hours See https://github.com/vector-im/riot-web/issues/9360 This is to prevent it from always working. Cookies without an expiration are supposed to expire at the end of the session, however the nature of mobile browsers means that the session is unlikely to ever end. --- src/vector/mobile_guide/index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/vector/mobile_guide/index.js b/src/vector/mobile_guide/index.js index 2c4785f39..9d8a44920 100644 --- a/src/vector/mobile_guide/index.js +++ b/src/vector/mobile_guide/index.js @@ -1,7 +1,8 @@ import {getVectorConfig} from '../getconfig'; function onBackToRiotClick() { - document.cookie = 'mobile_redirect_to_guide=false;path=/'; + // Cookie should expire in 24 hours + document.cookie = 'mobile_redirect_to_guide=false;path=/;max-age=86400'; window.location.href = '../'; } From 0d2668f2b16dadd9f613159a219da729f05422c2 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Wed, 3 Apr 2019 18:01:09 -0600 Subject: [PATCH 2/3] Step cookie down to 4 hours --- src/vector/mobile_guide/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/vector/mobile_guide/index.js b/src/vector/mobile_guide/index.js index 9d8a44920..b3cbff14a 100644 --- a/src/vector/mobile_guide/index.js +++ b/src/vector/mobile_guide/index.js @@ -1,8 +1,8 @@ import {getVectorConfig} from '../getconfig'; function onBackToRiotClick() { - // Cookie should expire in 24 hours - document.cookie = 'mobile_redirect_to_guide=false;path=/;max-age=86400'; + // Cookie should expire in 4 hours + document.cookie = 'mobile_redirect_to_guide=false;path=/;max-age=14400'; window.location.href = '../'; } From b72ae197e55077842184696981f6ca53e668a452 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Wed, 3 Apr 2019 18:11:25 -0600 Subject: [PATCH 3/3] Use a different cookie to expire any cookies people may already have We also check for a specific value in case people set it to `true` for some reason. --- src/vector/index.js | 2 +- src/vector/mobile_guide/index.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/vector/index.js b/src/vector/index.js index 6a70b7671..9d5c1dd42 100644 --- a/src/vector/index.js +++ b/src/vector/index.js @@ -272,7 +272,7 @@ async function loadApp() { const isIos = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream; const isAndroid = /Android/.test(navigator.userAgent); if (isIos || isAndroid) { - if (!document.cookie.split(';').some((c) => c.startsWith('mobile_redirect_to_guide'))) { + if (document.cookie.indexOf("riot_mobile_redirect_to_guide=false") === -1) { window.location = "mobile_guide/"; return; } diff --git a/src/vector/mobile_guide/index.js b/src/vector/mobile_guide/index.js index b3cbff14a..342643b47 100644 --- a/src/vector/mobile_guide/index.js +++ b/src/vector/mobile_guide/index.js @@ -2,7 +2,7 @@ import {getVectorConfig} from '../getconfig'; function onBackToRiotClick() { // Cookie should expire in 4 hours - document.cookie = 'mobile_redirect_to_guide=false;path=/;max-age=14400'; + document.cookie = 'riot_mobile_redirect_to_guide=false;path=/;max-age=14400'; window.location.href = '../'; }