Files
kulakpos_web/walkthroughs/2026-04-14_88427013_Walkthrough__Logout_Functionality.md
eko54r 05fd3230b8
All checks were successful
Build, Push and Deploy / build-and-push (push) Successful in 5m14s
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 17s
Build, Push and Deploy / deploy-staging (push) Successful in 41s
Build, Push and Deploy / deploy-production (push) Has been skipped
update marketing
2026-05-14 11:55:22 +07:00

2.0 KiB

Walkthrough - Logout Functionality

I have implemented the logout functionality in the Employee Portal.

Changes Made

Authentication State

  • Added a logout() function in auth_state.dart to reset all global session variables:
    • isLoggedIn set to false
    • loggedInNik, loggedInName, loggedInImage, loggedInPosition set to null

Layout

  • Implemented a confirmation dialog in root_layout.dart.
  • Connected the logout button (using LucideIcons.logOut) to trigger the dialog.
  • Clicking "OK" in the dialog will:
    1. Call the logout() function.
    2. Pop the dialog.
    3. Navigate the user back to the /login page.

Router

  • Enhanced the redirect logic in main.dart to enforce authentication:
    • If a user is not logged in (isLoggedIn == false), they are strictly redirected to /login for any protected route.
    • If a user is logged in, they are redirected away from /login to the dashboard.
    • This prevents users from using the browser's "back" button to return to the dashboard after logging out.

Verification Results

Code Quality

  • Verified that all necessary imports are present (go_router.dart, auth_state.dart).
  • Fixed class structure issues in root_layout.dart.

Logic Verification

  • The logout flow correctly handles session clearing before navigation.
  • The use of context.go('/login') ensures that the user is redirected to the login page and cannot easily navigate back to protected routes (as the redirect logic in main.dart will catch them if isLoggedIn is false).

Note

Since I cannot run the application in a live browser for this task, I have verified the implementation through code analysis.