Skip to content

refactor(controllers/web): dep-inject login and forgot-password payloads (#36659) - #40856

Merged
asukaminato0721 merged 1 commit into
langgenius:mainfrom
weike-zhang:chore/model-validate-web-auth
Aug 17, 2026
Merged

asukaminato0721 merged 1 commit into
langgenius:mainfrom
weike-zhang:chore/model-validate-web-auth

Conversation

@weike-zhang

Copy link
Copy Markdown
Contributor

Important

  1. Read CONTRIBUTING.md.
  2. Associated issue: dep inject model validate #36659.

Summary

#36659

Extends the @model_validate dependency-injection decorator to the remaining web auth handlers that still parsed their Pydantic schema inline from web_ns.payload / request.args:

  • ForgotPasswordSendEmailApi.post, ForgotPasswordCheckApi.post, ForgotPasswordResetApi.post (controllers/web/forgot_password.py)
  • LoginApi.post, LoginStatusApi.get, EmailCodeLoginSendEmailApi.post, EmailCodeLoginApi.post (controllers/web/login.py)

Each handler now receives its validated query/payload model as a parameter via @model_validate(Schema). LoginApi.post and EmailCodeLoginApi.post keep @decrypt_password_field / @decrypt_code_field outside @model_validate, so decryption still runs before validation.

No behavior change: request parsing, validation errors, and response shapes are identical.

Testing

  • uv run --project api pytest api/tests/unit_tests/controllers/web/test_web_forgot_password.py api/tests/unit_tests/controllers/web/test_web_login.py -o addopts= → 17 passed
  • uv run --project api ruff check / ruff format --check on the two changed files → clean

Existing unit tests still drive the decorated handlers through Flask test_request_context, so they cover the decorator path rather than calling inspect.unwrap.

Screenshots

Before After
N/A — backend-only controller refactor, no UI change N/A — backend-only controller refactor, no UI change

Checklist

  • This change requires a documentation update, included: Dify Document
  • I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.
  • I ran lint on the changed backend files. No frontend files changed.

From OpenCode

…ads (langgenius#36659)

Use @model_validate on the remaining web auth handlers so request
payloads are injected instead of parsed inline from web_ns.payload /
request.args. Matches the existing console/web controller pattern.
@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. refactor labels Aug 17, 2026
@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Aug 17, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Pyrefly Type Coverage

Metric Base PR Delta
Type coverage 59.18% 59.19% +0.00%
Strict coverage 58.76% 58.77% +0.00%
Typed symbols 39,433 39,440 +7
Untyped symbols 27,389 27,389 0
Modules 3167 3167 0

@asukaminato0721
asukaminato0721 added this pull request to the merge queue Aug 17, 2026
Merged via the queue into langgenius:main with commit 45be462 Aug 17, 2026
34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm This PR has been approved by a maintainer refactor size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants