ghamry03 / ft_transcendence

0 stars 0 forks source link

Changed main_app mechanism to fit the SPA scope #13

Closed ghamry03 closed 8 months ago

ghamry03 commented 8 months ago

VROOOM VROOOMMM ~~ V12 ENGINE NOISE ~~

This pull request (PR) refines the flow of the main_app while introducing a comprehensive login and logout mechanism. It focuses solely on backend modifications, ensuring seamless functionality and rendering.

WARNING

you need to change your intra API redirect uri to http://127.0.0.1:8000/authenticate

Changes:

Description:

Templates structure:

base.html
│   ├── mainContainer # utilized for 'login.html'
│   │   ├── mainContentContainer # utilized for 'home.html'
home.html
│   ├── topBar # # utilized for the topBar to enable seamless updates
│   ├── homeContentArea # utilized for 'homeCards.html' and various game modes

Injection flow

  '/home': () => {
    fetchMainContent('/home', 'mainContentArea')
      .then(() => fetchMainContent('/topbar', 'topBar'))
      .then(() => fetchMainContent('/cards', 'homeContentArea'))
      .then(() => injectScript('/static/js/token.js', 'homeContentArea', 'token'));
  },
  '/cards': () => {
    fetchMainContent('/cards', 'homeContentArea');
    removeScript('online');
    removeScript('offline')
  },
  '/offline': () => {
    fetchMainContent('/offline', 'homeContentArea')
      .then(() => injectScript('/static/js/offlinePong.js', 'homeContentArea', 'offline'));
  },
  '/online': () => {
    fetchMainContent('/online', 'homeContentArea')
      .then(() => injectScript('/static/js/canvas.js', 'homeContentArea', 'online'));
  },
  '/login': () => {
    fetchMainContent("/login", 'mainContainer');
  },
  '/logout': () => {
    fetchMainContent("/logout", 'mainContainer');
    clearInterval(pid);
    removeScript('token');
    removeScript('offline')
    removeScript('online')
  }
MehrinFirdousi commented 8 months ago

Clicking the back button from offline and online game pages logs the user out

MehrinFirdousi commented 8 months ago

Found 2 more issues after merging this with tournaments: