PageSourceSearch

https://www.lingoversa.com/js/history-blocker.js

js lingoversa.com collected 2026-10-02 01:35:24 UTC 1,677 bytes, 52 lines download raw bytes

1/**
2 * History Blocker
3 * Giriş yapmış kullanıcının geri tuşuyla login sayfasına dönmesini engeller.
4 *
5 * Oturum tespiti: `logged_out` cookie'sinin YOKLUĞU + sessionStorage cache
6 * kontrolü ile yapılır. `firebase_session` httpOnly olduğu için
7 * client-side'dan okunamaz; bu yüzden dolaylı sinyaller kullanılır.
8 */
9
10function isLoggedOut() {
11  if (document.cookie.includes('logged_out=true')) return true;
12  try {
13    var logoutAt = parseInt(localStorage.getItem('logout_at') || '0', 10);
14    if (logoutAt > 0 && Date.now() - logoutAt < 300000) return true;
15  } catch (_) { /* ignore */ }
16  return false;
17}
18
19function hasSessionCache() {
20  try {
21    var cached = sessionStorage.getItem('session_user');
22    if (cached) {
23      var data = JSON.parse(cached);
24      if (data && data.user && data.timestamp) return true;
25    }
26  } catch (_) { /* ignore */ }
27  return false;
28}
29
30function checkAuthAndRedirect() {
31  var currentPath = window.location.pathname;
32  var isAuthPage = currentPath.includes('/auth/login') || currentPath.includes('/auth/register');
33  if (!isAuthPage) return;
34
35  if (!isLoggedOut() && hasSessionCache()) {
36    window.location.replace('/dashboard');
37  }
38}
39
40document.addEventListener('DOMContentLoaded', checkAuthAndRedirect);
41window.addEventListener('popstate', checkAuthAndRedirect);
42
43window.blockLoginHistory = function(redirectUrl) {
44  redirectUrl = redirectUrl || window.location.pathname;
45  if (window.history && typeof window.history.replaceState === 'function') {
46    window.history.replaceState(null, '', redirectUrl);
47  }
48};
49
50window.addEventListener('auth-login-success', function() {
51  window.blockLoginHistory('/dashboard');
52});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.