Skip to content

Wallos: Open-source, self-hostable personal subscription tracker. Visualize your recurring expenses, manage your budget, and save money.

fix: vulnerability would allow to bypass 2fa (#1021)

Miguel Ribeiro90bb6186ee40
diff --git a/cronjobs b/cronjobs
index d4d15e7..ee85017 100644
--- a/cronjobs
+++ b/cronjobs
@@ -6,4 +6,5 @@
*/2 * * * * /usr/local/bin/php /var/www/html/endpoints/cronjobs/sendverificationemails.php >> /var/log/cron/sendverificationemails.log 2>&1
*/2 * * * * /usr/local/bin/php /var/www/html/endpoints/cronjobs/sendresetpasswordemails.php >> /var/log/cron/sendresetpasswordemails.log 2>&1
0 */6 * * * /usr/local/bin/php /var/www/html/endpoints/cronjobs/checkforupdates.php >> /var/log/cron/checkforupdates.log 2>&1
-30 1 * * 1 /usr/local/bin/php /var/www/html/endpoints/cronjobs/storetotalyearlycost.php >> /var/log/cron/storetotalyearlycost.log 2>&1
\ No newline at end of file
+30 1 * * 1 /usr/local/bin/php /var/www/html/endpoints/cronjobs/storetotalyearlycost.php >> /var/log/cron/storetotalyearlycost.log 2>&1
+0 3 * * * /usr/local/bin/php /var/www/html/endpoints/cronjobs/cleanupresettokens.php >> /var/log/cron/cleanupresettokens.log 2>&1
\ No newline at end of file
diff --git a/endpoints/cronjobs/cleanupresettokens.php b/endpoints/cronjobs/cleanupresettokens.php
new file mode 100644
index 0000000..fe8e12b
--- /dev/null
+++ b/endpoints/cronjobs/cleanupresettokens.php
@@ -0,0 +1,15 @@
+<?php
+
+require_once 'validate.php';
+require_once __DIR__ . '/../../includes/connect_endpoint_crontabs.php';
+
+$deleted = $db->exec("DELETE FROM password_resets WHERE created_at <= datetime('now', '-1 hour')");
+
+if ($deleted) {
+ echo "Expired password reset tokens cleaned up successfully.\n";
+} else {
+ echo "No expired password reset tokens to clean up.\n";
+}
+
+$db->close();
+?>
\ No newline at end of file
diff --git a/includes/header.php b/includes/header.php
index 593821c..a05ae04 100644
--- a/includes/header.php
+++ b/includes/header.php
@@ -151,6 +151,14 @@ $mobileNavigation = $settings['mobile_nav'] ? "mobile-navigation" : "";
?>
<script type="text/javascript" src="scripts/i18n/<?= $lang ?>.js?<?= $version ?>"></script>
<script type="text/javascript" src="scripts/i18n/getlang.js?<?= $version ?>"></script>
+ <script>
+ if ('serviceWorker' in navigator && navigator.serviceWorker.controller) {
+ if (!sessionStorage.getItem('sw_prefetched')) {
+ navigator.serviceWorker.controller.postMessage({ type: 'PREFETCH_PAGES' });
+ sessionStorage.setItem('sw_prefetched', '1');
+ }
+ }
+ </script>
</head>
<body class="<?= $theme ?> <?= $languages[$lang]['dir'] ?> <?= $mobileNavigation ?>">
diff --git a/includes/version.php b/includes/version.php
index 8c0dedc..a96ebe2 100644
--- a/includes/version.php
+++ b/includes/version.php
@@ -1,3 +1,3 @@
<?php
-$version = "v4.7.1";
+$version = "v4.7.2";
?>
\ No newline at end of file
diff --git a/login.php b/login.php
index 8a577b3..bc293f9 100644
--- a/login.php
+++ b/login.php
@@ -188,6 +188,17 @@ if (isset($_POST['username']) && isset($_POST['password'])) {
$userEmailWaitingVerification = true;
$loginFailed = true;
} else {
+ if ($totpEnabled['totp_enabled'] == 1) {
+ $_SESSION['totp_user_id'] = $userId;
+ if ($rememberMe) {
+ $_SESSION['pending_remember_me'] = true; // defer cookie until TOTP done
+ }
+ $db->close();
+ header("Location: totp.php");
+ exit();
+ }
+
+ // No TOTP — safe to create remember-me token now
if ($rememberMe) {
$token = bin2hex(random_bytes(32));
$addLoginTokens = "INSERT INTO login_tokens (user_id, token) VALUES (:userId, :token)";
@@ -204,14 +215,6 @@ if (isset($_POST['username']) && isset($_POST['password'])) {
]);
}
- // Send to totp page if 2fa is enabled
- if ($totpEnabled['totp_enabled'] == 1) {
- $_SESSION['totp_user_id'] = $userId;
- $db->close();
- header("Location: totp.php");
- exit();
- }
-
$_SESSION['username'] = $username;
$_SESSION['loggedin'] = true;
$_SESSION['main_currency'] = $main_currency;
diff --git a/logout.php b/logout.php
index bc2d6dd..338a1a2 100644
--- a/logout.php
+++ b/logout.php
@@ -35,5 +35,22 @@ if ($logoutOIDC && !empty($logoutUrl)) {
exit();
}
-header("Location: .");
+?>
+<!DOCTYPE html>
+<html>
+<head>
+<script>
+ async function clearAndRedirect() {
+ if ('caches' in window) {
+ await caches.delete('pages-cache-v1');
+ }
+ sessionStorage.removeItem('sw_prefetched');
+ window.location.href = '.';
+ }
+ clearAndRedirect();
+</script>
+</head>
+<body></body>
+</html>
+<?php
exit();
\ No newline at end of file
diff --git a/passwordreset.php b/passwordreset.php
index 5f59f61..982a7e9 100644
--- a/passwordreset.php
+++ b/passwordreset.php
@@ -72,7 +72,7 @@ if (isset($_GET['token']) && $_GET['token'] != "" && isset($_GET['email']) && $_
$resetMode = true;
$token = $_GET['token'];
$email = $_GET['email'];
- $matchCount = "SELECT COUNT(*) FROM password_resets WHERE token = :token and email = :email";
+ $matchCount = "SELECT COUNT(*) FROM password_resets WHERE token = :token AND email = :email AND created_at > datetime('now', '-1 hour')";
$stmt = $db->prepare($matchCount);
$stmt->bindValue(':token', $token, SQLITE3_TEXT);
$stmt->bindValue(':email', $email, SQLITE3_TEXT);
@@ -90,7 +90,7 @@ if (isset($_POST['password']) && $_POST['password'] != "" && isset($_POST['confi
$confirmPassword = $_POST['confirm_password'];
$token = $_POST['token'];
$email = $_POST['email'];
- $resetQuery = "SELECT * FROM password_resets WHERE token = :token AND email = :email";
+ $resetQuery = "SELECT * FROM password_resets WHERE token = :token AND email = :email AND created_at > datetime('now', '-1 hour')";
$stmt = $db->prepare($resetQuery);
$stmt->bindValue(':token', $token, SQLITE3_TEXT);
$stmt->bindValue(':email', $email, SQLITE3_TEXT);
@@ -104,8 +104,14 @@ if (isset($_POST['password']) && $_POST['password'] != "" && isset($_POST['confi
if ($password == $confirmPassword) {
$passwordHash = password_hash($password, PASSWORD_DEFAULT);
- $db->exec("UPDATE user SET password = '$passwordHash' WHERE id = " . $user['id']);
- $db->exec("DELETE FROM password_resets WHERE token = '$token'");
+ $stmt = $db->prepare("UPDATE user SET password = :password WHERE id = :id");
+ $stmt->bindValue(':password', $passwordHash, SQLITE3_TEXT);
+ $stmt->bindValue(':id', $user['id'], SQLITE3_INTEGER);
+ $stmt->execute();
+
+ $stmt = $db->prepare("DELETE FROM password_resets WHERE token = :token");
+ $stmt->bindValue(':token', $token, SQLITE3_TEXT);
+ $stmt->execute();
$hasSuccessMessage = true;
$hideForm = true;
} else {
diff --git a/service-worker.js b/service-worker.js
index 1117271..ba90996 100644
--- a/service-worker.js
+++ b/service-worker.js
@@ -1,194 +1,244 @@
+const STATIC_CACHE = 'static-cache-v1';
+const PAGES_CACHE = 'pages-cache-v1';
+const LOGOS_CACHE = 'logos-cache-v1';
+
+const staticAssets = [
+ 'manifest.json',
+ 'styles/styles.css',
+ 'styles/dark-theme.css',
+ 'styles/login.css',
+ 'styles/font-awesome.min.css',
+ 'styles/brands.css',
+ 'styles/barlow.css',
+ 'styles/themes/red.css',
+ 'styles/themes/green.css',
+ 'styles/themes/yellow.css',
+ 'styles/themes/purple.css',
+ 'webfonts/fa-solid-900.woff2',
+ 'webfonts/fa-solid-900.ttf',
+ 'webfonts/fa-brands-400.woff2',
+ 'webfonts/fa-brands-400.ttf',
+ 'webfonts/fa-regular-400.woff2',
+ 'webfonts/fa-regular-400.ttf',
+ 'scripts/common.js',
+ 'scripts/dashboard.js',
+ 'scripts/subscriptions.js',
+ 'scripts/stats.js',
+ 'scripts/settings.js',
+ 'scripts/theme.js',
+ 'scripts/notifications.js',
+ 'scripts/registration.js',
+ 'scripts/login.js',
+ 'scripts/admin.js',
+ 'scripts/calendar.js',
+ 'scripts/i18n/cs.js',
+ 'scripts/i18n/da.js',
+ 'scripts/i18n/de.js',
+ 'scripts/i18n/el.js',
+ 'scripts/i18n/en.js',
+ 'scripts/i18n/es.js',
+ 'scripts/i18n/fr.js',
+ 'scripts/i18n/id.js',
+ 'scripts/i18n/it.js',
+ 'scripts/i18n/jp.js',
+ 'scripts/i18n/ko.js',
+ 'scripts/i18n/nl.js',
+ 'scripts/i18n/pl.js',
+ 'scripts/i18n/pt.js',
+ 'scripts/i18n/pt_br.js',
+ 'scripts/i18n/ro.js',
+ 'scripts/i18n/ru.js',
+ 'scripts/i18n/sl.js',
+ 'scripts/i18n/sr_lat.js',
+ 'scripts/i18n/sr.js',
+ 'scripts/i18n/tr.js',
+ 'scripts/i18n/uk.js',
+ 'scripts/i18n/vi.js',
+ 'scripts/i18n/zh_cn.js',
+ 'scripts/i18n/zh_tw.js',
+ 'scripts/i18n/getlang.js',
+ 'scripts/libs/chart.js',
+ 'scripts/libs/sortable.min.js',
+ 'scripts/libs/qrcode.min.js',
+ 'images/icon/favicon.ico',
+ 'images/icon/android-chrome-192x192.png',
+ 'images/icon/apple-touch-icon-180',
+ 'images/icon/apple-touch-icon-152',
+ 'images/icon/apple-touch-icon',
+ 'images/screenshots/desktop.png',
+ 'images/siteicons/wallos.png',
+ 'images/siteicons/walloswhite.png',
+ 'images/siteimages/empty.png',
+ 'images/siteimages/mobilenav.png',
+ 'images/siteimages/mobilenavdark.png',
+ 'images/avatars/1.svg',
+ 'images/avatars/2.svg',
+ 'images/avatars/3.svg',
+ 'images/avatars/4.svg',
+ 'images/avatars/5.svg',
+ 'images/avatars/6.svg',
+ 'images/avatars/7.svg',
+ 'images/avatars/8.svg',
+ 'images/avatars/9.svg',
+ 'images/siteicons/svg/logo.php',
+ 'images/siteicons/svg/category.php',
+ 'images/siteicons/svg/check.php',
+ 'images/siteicons/svg/delete.php',
+ 'images/siteicons/svg/edit.php',
+ 'images/siteicons/svg/notes.php',
+ 'images/siteicons/scg/payment.php',
+ 'images/siteicons/svg/save.php',
+ 'images/siteicons/svg/subscription.php',
+ 'images/siteicons/svg/web.php',
+ 'images/siteicons/svg/websearch.php',
+ 'images/siteicons/svg/clone.php',
+ 'images/siteicons/svg/mobile-menu/calendar.php',
+ 'images/siteicons/svg/mobile-menu/home.php',
+ 'images/siteicons/svg/mobile-menu/profile.php',
+ 'images/siteicons/svg/mobile-menu/settings.php',
+ 'images/siteicons/svg/mobile-menu/statistics.php',
+ 'images/siteicons/svg/mobile-menu/subscriptions.php',
+ 'images/siteicons/pwa/stats.png',
+ 'images/siteicons/pwa/settings.png',
+ 'images/siteicons/pwa/about.png',
+ 'images/siteicons/pwa/calendar.png',
+ 'images/siteicons/pwa/subscriptions.png',
+ 'images/siteicons/pwa/dashboard.png',
+ 'images/uploads/icons/paypal.png',
+ 'images/uploads/icons/creditcard.png',
+ 'images/uploads/icons/banktransfer.png',
+ 'images/uploads/icons/directdebit.png',
+ 'images/uploads/icons/money.png',
+ 'images/uploads/icons/googlepay.png',
+ 'images/uploads/icons/samsungpay.png',
+ 'images/uploads/icons/applepay.png',
+ 'images/uploads/icons/crypto.png',
+ 'images/uploads/icons/klarna.png',
+ 'images/uploads/icons/amazonpay.png',
+ 'images/uploads/icons/sepa.png',
+ 'images/uploads/icons/skrill.png',
+ 'images/uploads/icons/sofort.png',
+ 'images/uploads/icons/stripe.png',
+ 'images/uploads/icons/affirm.png',
+ 'images/uploads/icons/alipay.png',
+ 'images/uploads/icons/elo.png',
+ 'images/uploads/icons/facebookpay.png',
+ 'images/uploads/icons/giropay.png',
+ 'images/uploads/icons/ideal.png',
+ 'images/uploads/icons/unionpay.png',
+ 'images/uploads/icons/interac.png',
+ 'images/uploads/icons/wechat.png',
+ 'images/uploads/icons/paysafe.png',
+ 'images/uploads/icons/poli.png',
+ 'images/uploads/icons/qiwi.png',
+ 'images/uploads/icons/shoppay.png',
+ 'images/uploads/icons/venmo.png',
+ 'images/uploads/icons/verifone.png',
+ 'images/uploads/icons/webmoney.png',
+];
+
+const pagesToPrefetch = [
+ 'index.php',
+ 'subscriptions.php',
+ 'profile.php',
+ 'calendar.php',
+ 'settings.php',
+ 'stats.php',
+ 'about.php',
+ 'login.php',
+ 'admin.php',
+];
+
+// Install: cache static assets only
self.addEventListener('install', function (event) {
event.waitUntil(
- caches.open('my-cache').then(function (cache) {
- const urlsToCache = [
- '.',
- 'index.php',
- 'subscriptions.php',
- 'profile.php',
- 'calendar.php',
- 'settings.php',
- 'stats.php',
- 'about.php',
- 'login.php',
- 'admin.php',
- 'endpoints/subscriptions/get.php',
- 'manifest.json',
- 'styles/styles.css',
- 'styles/dark-theme.css',
- 'styles/login.css',
- 'styles/font-awesome.min.css',
- 'styles/brands.css',
- 'styles/barlow.css',
- 'styles/themes/red.css',
- 'styles/themes/green.css',
- 'styles/themes/yellow.css',
- 'styles/themes/purple.css',
- 'webfonts/fa-solid-900.woff2',
- 'webfonts/fa-solid-900.ttf',
- 'webfonts/fa-brands-400.woff2',
- 'webfonts/fa-brands-400.ttf',
- 'webfonts/fa-regular-400.woff2',
- 'webfonts/fa-regular-400.ttf',
- 'scripts/common.js',
- 'scripts/dashboard.js',
- 'scripts/subscriptions.js',
- 'scripts/stats.js',
- 'scripts/settings.js',
- 'scripts/theme.js',
- 'scripts/notifications.js',
- 'scripts/registration.js',
- 'scripts/login.js',
- 'scripts/admin.js',
- 'scripts/calendar.js',
- 'scripts/i18n/cs.js',
- 'scripts/i18n/da.js',
- 'scripts/i18n/de.js',
- 'scripts/i18n/el.js',
- 'scripts/i18n/en.js',
- 'scripts/i18n/es.js',
- 'scripts/i18n/fr.js',
- 'scripts/i18n/id.js',
- 'scripts/i18n/it.js',
- 'scripts/i18n/jp.js',
- 'scripts/i18n/ko.js',
- 'scripts/i18n/nl.js',
- 'scripts/i18n/pl.js',
- 'scripts/i18n/pt.js',
- 'scripts/i18n/pt_br.js',
- 'scripts/i18n/ru.js',
- 'scripts/i18n/sl.js',
- 'scripts/i18n/sr_lat.js',
- 'scripts/i18n/sr.js',
- 'scripts/i18n/tr.js',
- 'scripts/i18n/uk.js',
- 'scripts/i18n/vi.js',
- 'scripts/i18n/zh_cn.js',
- 'scripts/i18n/zh_tw.js',
- 'scripts/i18n/getlang.js',
- 'scripts/libs/chart.js',
- 'scripts/libs/sortable.min.js',
- 'scripts/libs/qrcode.min.js',
- 'images/icon/favicon.ico',
- 'images/icon/android-chrome-192x192.png',
- 'images/icon/apple-touch-icon-180',
- 'images/icon/apple-touch-icon-152',
- 'images/icon/apple-touch-icon',
- 'images/screenshots/desktop.png',
- 'images/siteicons/wallos.png',
- 'images/siteicons/walloswhite.png',
- 'images/siteimages/empty.png',
- 'images/siteimages/mobilenav.png',
- 'images/siteimages/mobilenavdark.png',
- 'images/avatars/1.svg',
- 'images/avatars/2.svg',
- 'images/avatars/3.svg',
- 'images/avatars/4.svg',
- 'images/avatars/5.svg',
- 'images/avatars/6.svg',
- 'images/avatars/7.svg',
- 'images/avatars/8.svg',
- 'images/avatars/9.svg',
- 'images/siteicons/svg/logo.php',
- 'images/siteicons/svg/category.php',
- 'images/siteicons/svg/check.php',
- 'images/siteicons/svg/delete.php',
- 'images/siteicons/svg/edit.php',
- 'images/siteicons/svg/notes.php',
- 'images/siteicons/scg/payment.php',
- 'images/siteicons/svg/save.php',
- 'images/siteicons/svg/subscription.php',
- 'images/siteicons/svg/web.php',
- 'images/siteicons/svg/websearch.php',
- 'images/siteicons/svg/clone.php',
- 'images/siteicons/svg/mobile-menu/calendar.php',
- 'images/siteicons/svg/mobile-menu/home.php',
- 'images/siteicons/svg/mobile-menu/profile.php',
- 'images/siteicons/svg/mobile-menu/settings.php',
- 'images/siteicons/svg/mobile-menu/statistics.php',
- 'images/siteicons/svg/mobile-menu/subscriptions.php',
- 'images/siteicons/pwa/stats.png',
- 'images/siteicons/pwa/settings.png',
- 'images/siteicons/pwa/about.png',
- 'images/siteicons/pwa/calendar.png',
- 'images/siteicons/pwa/subscriptions.png',
- 'images/siteicons/pwa/dashboard.png',
- 'images/uploads/icons/paypal.png',
- 'images/uploads/icons/creditcard.png',
- 'images/uploads/icons/banktransfer.png',
- 'images/uploads/icons/directdebit.png',
- 'images/uploads/icons/money.png',
- 'images/uploads/icons/googlepay.png',
- 'images/uploads/icons/samsungpay.png',
- 'images/uploads/icons/applepay.png',
- 'images/uploads/icons/crypto.png',
- 'images/uploads/icons/klarna.png',
- 'images/uploads/icons/amazonpay.png',
- 'images/uploads/icons/sepa.png',
- 'images/uploads/icons/skrill.png',
- 'images/uploads/icons/sofort.png',
- 'images/uploads/icons/stripe.png',
- 'images/uploads/icons/affirm.png',
- 'images/uploads/icons/alipay.png',
- 'images/uploads/icons/elo.png',
- 'images/uploads/icons/facebookpay.png',
- 'images/uploads/icons/giropay.png',
- 'images/uploads/icons/ideal.png',
- 'images/uploads/icons/unionpay.png',
- 'images/uploads/icons/interac.png',
- 'images/uploads/icons/wechat.png',
- 'images/uploads/icons/paysafe.png',
- 'images/uploads/icons/poli.png',
- 'images/uploads/icons/qiwi.png',
- 'images/uploads/icons/shoppay.png',
- 'images/uploads/icons/venmo.png',
- 'images/uploads/icons/verifone.png',
- 'images/uploads/icons/webmoney.png',
- ];
+ caches.open(STATIC_CACHE).then(function (cache) {
+ return Promise.allSettled(
+ staticAssets.map(url =>
+ fetch(url).then(response => {
+ if (response.ok) cache.put(url, response);
+ }).catch(() => {}) // silently skip missing files
+ )
+ );
+ })
+ );
+ self.skipWaiting();
+});
+
+// Activate: clean up old caches
+self.addEventListener('activate', function (event) {
+ const validCaches = [STATIC_CACHE, PAGES_CACHE, LOGOS_CACHE];
+ event.waitUntil(
+ caches.keys().then(keys =>
+ Promise.all(
+ keys.filter(key => !validCaches.includes(key))
+ .map(key => caches.delete(key))
+ )
+ )
+ );
+ self.clients.claim();
+});
- urlsToCache.forEach(function (url) {
- fetch(url).then(function (response) {
- if (response.ok) {
+// Message: prefetch pages after login
+self.addEventListener('message', function (event) {
+ if (event.data && event.data.type === 'PREFETCH_PAGES') {
+ caches.open(PAGES_CACHE).then(cache => {
+ pagesToPrefetch.forEach(url => {
+ fetch(url).then(response => {
+ // Only cache if user is actually logged in (no redirect)
+ if (response.ok && !response.redirected) {
cache.put(url, response);
}
- });
+ }).catch(() => {});
});
- })
- );
+ });
+ }
});
+// Fetch: single handler for all requests
self.addEventListener('fetch', function (event) {
- event.respondWith(
- fetch(event.request.clone()).then(function (response) {
- // Check if the response is a redirect
- if (response.redirected) {
- // If the response is a redirect, follow it by making a new fetch request
- return fetch(response.url);
- } else {
- // If the response is not a redirect, return it as-is
- return response;
- }
- }).catch(function (error) {
- // If fetching fails, try to retrieve the response from cache
- return caches.match(event.request, { ignoreSearch: true });
- })
- );
-});
+ const request = event.request;
+ const url = new URL(request.url);
+
+ // Never intercept non-GET requests (POST, etc.)
+ if (request.method !== 'GET') return;
-self.addEventListener('fetch', event => {
- const url = new URL(event.request.url);
- // Check if the request is for an image in the logos directory
+ // Logo images: cache-first, populate on first load
if (url.pathname.includes('images/uploads/logos')) {
event.respondWith(
- caches.match(event.request).then(response => {
- return response || fetch(event.request).then(response => {
- // Open a specific cache and cache the response for future requests
- return caches.open('logos-cache').then(cache => {
- cache.put(event.request, response.clone());
- return response;
+ caches.match(request).then(response => {
+ return response || fetch(request).then(networkResponse => {
+ return caches.open(LOGOS_CACHE).then(cache => {
+ cache.put(request, networkResponse.clone());
+ return networkResponse;
});
});
})
);
+ return;
+ }
+
+ // Static assets: cache-first (they only change on deploy)
+ if (staticAssets.some(asset => url.pathname.endsWith(asset))) {
+ event.respondWith(
+ caches.match(request).then(response => response || fetch(request))
+ );
+ return;
}
-});
\ No newline at end of file
+
+ // PHP pages and everything else: network-first, cache as fallback
+ // Also update the pages cache on every successful load
+ event.respondWith(
+ fetch(request).then(response => {
+ if (response.ok && !response.redirected) {
+ const responseClone = response.clone(); // clone before any async operation
+ caches.open(PAGES_CACHE).then(cache => {
+ cache.put(request, responseClone);
+ });
+ }
+ return response;
+ }).catch(() => {
+ return caches.match(request, { ignoreSearch: true });
+ })
+ );
+});
diff --git a/styles/styles.css b/styles/styles.css
index b695d3e..aed1bf4 100644
--- a/styles/styles.css
+++ b/styles/styles.css
@@ -3103,4 +3103,13 @@ input[type="radio"]:checked+label::after {
.spinner.ai-spinner {
margin: auto;
}
+}
+
+.dashboard-subscriptions-container {
+ scrollbar-width: none;
+ -ms-overflow-style: none;
+}
+
+.dashboard-subscriptions-container::-webkit-scrollbar {
+ display: none;
}
\ No newline at end of file
diff --git a/totp.php b/totp.php
index 047b3cd..a9d76fa 100644
--- a/totp.php
+++ b/totp.php
@@ -108,6 +108,24 @@ if (isset($_POST['one-time-code'])) {
$_SESSION['loggedin'] = true;
$_SESSION['main_currency'] = $user['main_currency'];
$_SESSION['userId'] = $user['id'];
+
+ if (!empty($_SESSION['pending_remember_me'])) {
+ $token = bin2hex(random_bytes(32));
+ $addLoginTokens = "INSERT INTO login_tokens (user_id, token) VALUES (:userId, :token)";
+ $addLoginTokensStmt = $db->prepare($addLoginTokens);
+ $addLoginTokensStmt->bindParam(':userId', $user['id'], SQLITE3_INTEGER);
+ $addLoginTokensStmt->bindParam(':token', $token, SQLITE3_TEXT);
+ $addLoginTokensStmt->execute();
+ $cookieExpire = time() + (30 * 24 * 60 * 60);
+ $cookieValue = $user['username'] . "|" . $token . "|" . $user['main_currency'];
+ setcookie('wallos_login', $cookieValue, [
+ 'expires' => $cookieExpire,
+ 'samesite' => 'Strict',
+ 'httponly' => true,
+ ]);
+ unset($_SESSION['pending_remember_me']);
+ }
+
setcookie('language', $user['language'], [
'expires' => $cookieExpire,
'samesite' => 'Strict'