Authentication in the Pokédex Web App uses Flask’s built-in server-side session. After a successful login,Documentation Index
Fetch the complete documentation index at: https://mintlify.com/Navi-27/Proyecto-UPC/llms.txt
Use this file to discover all available pages before exploring further.
usuario_id and username are stored in the session cookie, which is signed with the app’s secret key (pokesecretkey123 by default). No external authentication library is required — credentials are verified locally by querying the SQLite usuarios table and running Werkzeug’s check_password_hash against the stored hash.
Login Flow
Navigate to /login
Open
/login in your browser. The Iniciar Sesión page is rendered with a two-field form (username and password) and a link to /registro for users who do not yet have an account.Enter your username and password
Fill in the Usuario and Contraseña fields. Both are marked
required, so the browser will block submission if either is empty.The server verifies your credentials
On
POST /login, the server calls Usuario.login(username, password), which:- Executes
SELECT * FROM usuarios WHERE username = ?against theusuariostable. - Passes the stored hash and the supplied plain-text password to
werkzeug.security.check_password_hash. - Returns a
Usuario(id, username)instance on a successful match, orNoneif the username does not exist or the password is wrong.
Success — session created and redirected to /
When
Usuario.login returns a Usuario object, the server writes two values into the Flask session:session['usuario_id']— the integer primary key from theusuariostable.session['username']— the display name string shown in the navigation.
/) via url_for("index").Logout Flow
Logging out requires no form submission. Simply navigate toGET /logout (for example, by clicking a Logout link that points to /logout). The server calls session.clear(), which removes all session keys including usuario_id and username, then redirects to the home page (/).
/login.
Session Data Reference
| Key | Type | Value |
|---|---|---|
session['usuario_id'] | int | Auto-incremented primary key from the usuarios table. Used to scope team and Pokédex data to the current user. |
session['username'] | str | Plain-text username as stored in the database. Displayed in the UI. |
Protected Routes
The following routes check for an active session before serving content. Unauthenticated requests receive a302 redirect to /login:
My Pokédex
GET /mi-pokedex — Lists every Pokémon the logged-in user has viewed on their detail page. Automatically tracked when you visit /pokemon/<nombre> while signed in.My Team
GET /equipo — Displays the current user’s saved team of up to six Pokémon.Add to Team
GET /equipo/agregar/<pokemon_id>/<nombre>/<imagen>/<tipos> — Adds a Pokémon to the current user’s team. Requires an active session; otherwise redirected to /login.Remove from Team
GET /equipo/eliminar/<pokemon_id> — Removes a Pokémon from the current user’s team. Requires an active session; otherwise redirected to /login.