[PR #2003] [CLOSED] Restore password via email #7654

Closed
opened 2025-11-11 17:32:29 -06:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/2003
Author: @juliojesusvizcaino
Created: 5/6/2024
Status: Closed

Base: devHead: restore-password


📝 Commits (3)

  • 32ea131 Restore password via forgot password email
  • 4bcc785 Extend reset password token validity to 7 days, include plain text link in email
  • 17ad70b Rename mail to email

📊 Changes

45 files changed (+698 additions, -30 deletions)

View changed files

📝 .env.example (+13 -1)
📝 backend/apps/web/models/auths.py (+7 -0)
📝 backend/apps/web/routers/auths.py (+51 -6)
📝 backend/config.py (+43 -0)
📝 backend/main.py (+2 -0)
📝 backend/requirements.txt (+1 -0)
backend/utils/reset_password.py (+90 -0)
📝 src/lib/apis/auths/index.ts (+36 -0)
📝 src/lib/i18n/locales/ar-BH/translation.json (+9 -0)
📝 src/lib/i18n/locales/bg-BG/translation.json (+9 -0)
📝 src/lib/i18n/locales/bn-BD/translation.json (+9 -0)
📝 src/lib/i18n/locales/ca-ES/translation.json (+9 -0)
📝 src/lib/i18n/locales/de-DE/translation.json (+10 -1)
📝 src/lib/i18n/locales/dg-DG/translation.json (+9 -0)
📝 src/lib/i18n/locales/en-GB/translation.json (+9 -0)
📝 src/lib/i18n/locales/en-US/translation.json (+9 -0)
📝 src/lib/i18n/locales/es-ES/translation.json (+9 -0)
📝 src/lib/i18n/locales/fa-IR/translation.json (+9 -0)
📝 src/lib/i18n/locales/fi-FI/translation.json (+9 -0)
📝 src/lib/i18n/locales/fr-CA/translation.json (+9 -0)

...and 25 more files

📄 Description

Pull Request Checklist

  • Description: Briefly describe the changes in this pull request.
  • Changelog: Ensure a changelog entry following the format of Keep a Changelog is added at the bottom of the PR description.
  • Documentation: Have you updated relevant documentation Open WebUI Docs, or other documentation sources?
  • Dependencies: Are there any new dependencies? Have you updated the dependency versions in the documentation?
  • Testing: Have you written and run sufficient tests for the changes?
  • Code Review: Have you self-reviewed your code and addressed any coding standard issues?

Description

Allow users to restore their password via email.

Changelog Entry

Added

  • Allow users to restore their password via email.

Additional Information

  • Show a link to the users "Forgot your password?". Write the email and click on "Send Reset Email". It makes a POST request to /api/v1/auths/request-password-reset
  • The endpoint returns, and a background task runs for email sending.
    • It checks if the user exists.
    • It creates a JWT identifying the user. It includes the start of the hash (sha256) of the current password, so it can't be used twice to change the user password.
    • It renders a basic HTML template with a link to the frontend/auth/reset-password?token=<the jwt>.
    • It sends the email.
  • The user receives the email and clicks on the Reset Password link.
  • They are redirected to frontend/auth/reset-password?token=<the jwt>.
  • They enter the new password and Reset Password. It makes a POST request to /api/v1/auths/reset-password.
  • In the endpoint, the token is checked and the password is changed.
  • The user is redirected to the login page.

For this to work, configure some environment variables:

ENABLE_MAIL="True"
MAIL_USERNAME="user@example.com"
MAIL_PASSWORD=""
MAIL_FROM="user@example.com"
MAIL_PORT="587"
MAIL_SERVER="smtp.gmail.com"
MAIL_FROM_NAME="Desired Name"
MAIL_STARTTLS="True"
MAIL_SSL_TLS="False"

FRONTEND_URL="http://localhost:5173"

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/open-webui/open-webui/pull/2003 **Author:** [@juliojesusvizcaino](https://github.com/juliojesusvizcaino) **Created:** 5/6/2024 **Status:** ❌ Closed **Base:** `dev` ← **Head:** `restore-password` --- ### 📝 Commits (3) - [`32ea131`](https://github.com/open-webui/open-webui/commit/32ea131725a46ba0aa12a132b6dcbb1443895400) Restore password via forgot password email - [`4bcc785`](https://github.com/open-webui/open-webui/commit/4bcc78591fd9a2b17c6e22d0f33bf268ac476d46) Extend reset password token validity to 7 days, include plain text link in email - [`17ad70b`](https://github.com/open-webui/open-webui/commit/17ad70bcf19dbbdb36279d487cb66c791db3538e) Rename mail to email ### 📊 Changes **45 files changed** (+698 additions, -30 deletions) <details> <summary>View changed files</summary> 📝 `.env.example` (+13 -1) 📝 `backend/apps/web/models/auths.py` (+7 -0) 📝 `backend/apps/web/routers/auths.py` (+51 -6) 📝 `backend/config.py` (+43 -0) 📝 `backend/main.py` (+2 -0) 📝 `backend/requirements.txt` (+1 -0) ➕ `backend/utils/reset_password.py` (+90 -0) 📝 `src/lib/apis/auths/index.ts` (+36 -0) 📝 `src/lib/i18n/locales/ar-BH/translation.json` (+9 -0) 📝 `src/lib/i18n/locales/bg-BG/translation.json` (+9 -0) 📝 `src/lib/i18n/locales/bn-BD/translation.json` (+9 -0) 📝 `src/lib/i18n/locales/ca-ES/translation.json` (+9 -0) 📝 `src/lib/i18n/locales/de-DE/translation.json` (+10 -1) 📝 `src/lib/i18n/locales/dg-DG/translation.json` (+9 -0) 📝 `src/lib/i18n/locales/en-GB/translation.json` (+9 -0) 📝 `src/lib/i18n/locales/en-US/translation.json` (+9 -0) 📝 `src/lib/i18n/locales/es-ES/translation.json` (+9 -0) 📝 `src/lib/i18n/locales/fa-IR/translation.json` (+9 -0) 📝 `src/lib/i18n/locales/fi-FI/translation.json` (+9 -0) 📝 `src/lib/i18n/locales/fr-CA/translation.json` (+9 -0) _...and 25 more files_ </details> ### 📄 Description ## Pull Request Checklist - [x] **Description:** Briefly describe the changes in this pull request. - [x] **Changelog:** Ensure a changelog entry following the format of [Keep a Changelog](https://keepachangelog.com/) is added at the bottom of the PR description. - [x] **Documentation:** Have you updated relevant documentation [Open WebUI Docs](https://github.com/open-webui/docs), or other documentation sources? - [x] **Dependencies:** Are there any new dependencies? Have you updated the dependency versions in the documentation? - [x] **Testing:** Have you written and run sufficient tests for the changes? - [x] **Code Review:** Have you self-reviewed your code and addressed any coding standard issues? --- ## Description Allow users to restore their password via email. --- ### Changelog Entry ### Added - Allow users to restore their password via email. --- ### Additional Information - Show a link to the users "Forgot your password?". Write the email and click on "Send Reset Email". It makes a POST request to `/api/v1/auths/request-password-reset` - The endpoint returns, and a background task runs for email sending. - It checks if the user exists. - It creates a JWT identifying the user. It includes the start of the hash (sha256) of the current password, so it can't be used twice to change the user password. - It renders a basic HTML template with a link to the `frontend/auth/reset-password?token=<the jwt>`. - It sends the email. - The user receives the email and clicks on the `Reset Password` link. - They are redirected to `frontend/auth/reset-password?token=<the jwt>`. - They enter the new password and `Reset Password`. It makes a POST request to `/api/v1/auths/reset-password`. - In the endpoint, the token is checked and the password is changed. - The user is redirected to the login page. For this to work, configure some environment variables: ```sh ENABLE_MAIL="True" MAIL_USERNAME="user@example.com" MAIL_PASSWORD="" MAIL_FROM="user@example.com" MAIL_PORT="587" MAIL_SERVER="smtp.gmail.com" MAIL_FROM_NAME="Desired Name" MAIL_STARTTLS="True" MAIL_SSL_TLS="False" FRONTEND_URL="http://localhost:5173" ``` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2025-11-11 17:32:30 -06:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#7654