> ## Documentation Index
> Fetch the complete documentation index at: https://kxp.wyhil.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Logout

> Learn how to create logout modules using Prometheus.

## Logout Feature Overview

**Logout** is a key step in security that safely destroys the user's authentication state to block others from stealing the account. In accordance with the previously implemented login method (JWT, etc.), we implement the process of invalidating both client and server-side authentication information through Vibe Coding.

***

## Step-by-Step Logout Implementation

### 1. Establish a Logout Strategy

Request the optimal logout logic from the AI based on the authentication method being used.

> **Prompt:** "I want to create a bulletin board logout function. I need to invalidate the JWT token held by the client, and so I should also create logic for the server side to register that token in a Blacklist so it can no longer be used."

### 2. Logout Logic Creation (Logic Create)

The AI creates a dedicated handler for session destruction or token expiration processing.

* **Using Tools**: The AI uses `edit_existing_file` to register a logout endpoint in `SecurityConfig` and sets the page to be redirected to upon a successful logout.

### 3. UI and Navigation Update (Layout Change)

Modify the layout so that the button in the header changes from 'Login' to 'Logout' depending on the user's login status.

> **Prompt:** "Update the header layout. If the user is logged in, show a 'Logout' button and put in JavaScript code so that the logout API we just created is called when it's clicked."

***

## 💡 Checklist for Secure Logout

* **Clean up Client Storage**: Ensure that user information and tokens stored in the browser's `localStorage` or `Cookie` are completely deleted upon logout.
* **Cache Control**: It's recommended to request the AI to set `Cache-Control` headers so that sensitive board writing pages don't reappear when the back button is pressed after logging out.
* **Redirection**: Once the logout is complete, you should show a "You have been logged out" message to the user or naturally move them to the main screen.

***
