implement logout
This commit is contained in:
parent
d03f6ce7be
commit
da2563c527
@ -104,6 +104,11 @@ if __name__ == "__main__":
|
|||||||
name="ForgotPassword",
|
name="ForgotPassword",
|
||||||
page_url="forgot-password",
|
page_url="forgot-password",
|
||||||
build=lambda: pages.PlaceholderPage(placeholder_name="Passwort vergessen"),
|
build=lambda: pages.PlaceholderPage(placeholder_name="Passwort vergessen"),
|
||||||
|
),
|
||||||
|
Page(
|
||||||
|
name="Logout",
|
||||||
|
page_url="logout",
|
||||||
|
build=pages.LogoutPage,
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
theme=theme,
|
theme=theme,
|
||||||
|
|||||||
25
src/ez_lan_manager/components/MainViewContentBox.py
Normal file
25
src/ez_lan_manager/components/MainViewContentBox.py
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
from typing import Optional
|
||||||
|
|
||||||
|
from rio import Component, Rectangle, Text
|
||||||
|
|
||||||
|
|
||||||
|
class MainViewContentBox(Component):
|
||||||
|
content: Optional[Component] = None
|
||||||
|
|
||||||
|
def build(self) -> Component:
|
||||||
|
if self.content is None:
|
||||||
|
content = Text("Vielleich sollte hier etwas sein...\n\n\n... Wenn ja, habe ich es nicht gefunden. :(")
|
||||||
|
else:
|
||||||
|
content = self.content
|
||||||
|
return Rectangle(
|
||||||
|
content=content,
|
||||||
|
fill=self.session.theme.primary_color,
|
||||||
|
margin_left=1,
|
||||||
|
margin_right=1,
|
||||||
|
margin_top=2,
|
||||||
|
margin_bottom=1,
|
||||||
|
shadow_radius=0.5,
|
||||||
|
shadow_color=self.session.theme.hud_color,
|
||||||
|
shadow_offset_y=0,
|
||||||
|
corner_radius=0.2
|
||||||
|
)
|
||||||
@ -2,7 +2,7 @@ from random import choice
|
|||||||
|
|
||||||
from rio import Component, Card, Column, Text, Row, Rectangle, Button, TextStyle, Color, Spacer, TextInput, Link
|
from rio import Component, Card, Column, Text, Row, Rectangle, Button, TextStyle, Color, Spacer, TextInput, Link
|
||||||
|
|
||||||
from src.ez_lan_manager import UserService, AccountingService
|
from src.ez_lan_manager import UserService, AccountingService, TicketingService, SeatingService
|
||||||
from src.ez_lan_manager.components.UserInfoBoxButton import UserInfoBoxButton
|
from src.ez_lan_manager.components.UserInfoBoxButton import UserInfoBoxButton
|
||||||
from src.ez_lan_manager.types.SessionStorage import SessionStorage
|
from src.ez_lan_manager.types.SessionStorage import SessionStorage
|
||||||
|
|
||||||
@ -45,8 +45,8 @@ class UserInfoBox(Component):
|
|||||||
Text(f"{self.get_greeting()},", style=TextStyle(fill=Color.from_hex("02dac5"), font_size=0.9), justify="center"),
|
Text(f"{self.get_greeting()},", style=TextStyle(fill=Color.from_hex("02dac5"), font_size=0.9), justify="center"),
|
||||||
Text(f"{user.user_name}", style=TextStyle(fill=Color.from_hex("02dac5"), font_size=1.2), justify="center"),
|
Text(f"{user.user_name}", style=TextStyle(fill=Color.from_hex("02dac5"), font_size=1.2), justify="center"),
|
||||||
Row(
|
Row(
|
||||||
StatusButton(label="TICKET", target_url="", enabled=True),
|
StatusButton(label="TICKET", target_url="./buy_ticket", enabled=self.session[TicketingService].get_user_ticket(user.user_id) is not None),
|
||||||
StatusButton(label="SITZPLATZ", target_url="", enabled=False),
|
StatusButton(label="SITZPLATZ", target_url="./seating", enabled=self.session[SeatingService].get_user_seat(user.user_id) is not None),
|
||||||
proportions=(50, 50),
|
proportions=(50, 50),
|
||||||
grow_y=False
|
grow_y=False
|
||||||
),
|
),
|
||||||
|
|||||||
30
src/ez_lan_manager/pages/Logout.py
Normal file
30
src/ez_lan_manager/pages/Logout.py
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
from rio import Column, Component, event, Text, TextStyle
|
||||||
|
|
||||||
|
from src.ez_lan_manager import ConfigurationService
|
||||||
|
from src.ez_lan_manager.components.MainViewContentBox import MainViewContentBox
|
||||||
|
from src.ez_lan_manager.pages import BasePage
|
||||||
|
from src.ez_lan_manager.types.SessionStorage import SessionStorage
|
||||||
|
|
||||||
|
|
||||||
|
class LogoutPage(Component):
|
||||||
|
@event.on_populate
|
||||||
|
async def on_populate(self) -> None:
|
||||||
|
await self.session.set_title(f"{self.session[ConfigurationService].get_lan_info().name} - Logout")
|
||||||
|
|
||||||
|
def build(self) -> Component:
|
||||||
|
self.session[SessionStorage].clear()
|
||||||
|
return BasePage(
|
||||||
|
content=Column(
|
||||||
|
MainViewContentBox(
|
||||||
|
content=Text(
|
||||||
|
"Auf wiedersehen o/",
|
||||||
|
style=TextStyle(
|
||||||
|
fill=self.session.theme.background_color,
|
||||||
|
font_size=1.4
|
||||||
|
),
|
||||||
|
margin=2
|
||||||
|
)
|
||||||
|
),
|
||||||
|
align_y=0,
|
||||||
|
)
|
||||||
|
)
|
||||||
@ -1,3 +1,4 @@
|
|||||||
from .BasePage import BasePage
|
from .BasePage import BasePage
|
||||||
from .NewsPage import NewsPage
|
from .NewsPage import NewsPage
|
||||||
from .PlaceholderPage import PlaceholderPage
|
from .PlaceholderPage import PlaceholderPage
|
||||||
|
from .Logout import LogoutPage
|
||||||
|
|||||||
@ -7,3 +7,6 @@ from typing import Optional
|
|||||||
@dataclass(frozen=False)
|
@dataclass(frozen=False)
|
||||||
class SessionStorage:
|
class SessionStorage:
|
||||||
user_id: Optional[int] = None # DEBUG: Put user ID here to skip login
|
user_id: Optional[int] = None # DEBUG: Put user ID here to skip login
|
||||||
|
|
||||||
|
def clear(self) -> None:
|
||||||
|
self.user_id = None
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user