update marketing
All checks were successful
All checks were successful
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
# 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](file:///home/itc43/Documents/HOKBEN_PROJECT/ESS%20PROJECT/Employee%20Portal%20Design/flutter-code/lib/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](file:///home/itc43/Documents/HOKBEN_PROJECT/ESS%20PROJECT/Employee%20Portal%20Design/flutter-code/lib/layout/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](file:///home/itc43/Documents/HOKBEN_PROJECT/ESS%20PROJECT/Employee%20Portal%20Design/flutter-code/lib/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.
|
||||
Reference in New Issue
Block a user