mirror of
https://github.com/langgenius/dify.git
synced 2026-07-25 21:48:30 +08:00
feat(oauth): expose stable account id on provider account endpoint (#39470)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
parent
a8a83a357c
commit
922ed4d67d
@ -56,6 +56,7 @@ class OAuthProviderTokenResponse(BaseModel):
|
||||
|
||||
|
||||
class OAuthProviderAccountResponse(BaseModel):
|
||||
id: str
|
||||
name: str
|
||||
email: str
|
||||
avatar: str | None = None
|
||||
@ -251,6 +252,7 @@ class OAuthServerUserAccountApi(Resource):
|
||||
def post(self, oauth_provider_app: OAuthProviderApp, account: Account):
|
||||
return jsonable_encoder(
|
||||
{
|
||||
"id": account.id,
|
||||
"name": account.name,
|
||||
"email": account.email,
|
||||
"avatar": account.avatar,
|
||||
|
||||
@ -19559,6 +19559,7 @@ Coarse node-level status used by Inspector to pick a banner.
|
||||
| ---- | ---- | ----------- | -------- |
|
||||
| avatar | string | | No |
|
||||
| email | string | | Yes |
|
||||
| id | string | | Yes |
|
||||
| interface_language | string | | Yes |
|
||||
| name | string | | Yes |
|
||||
| timezone | string | | Yes |
|
||||
|
||||
@ -318,6 +318,7 @@ def test_oauth_account_successful_retrieval(
|
||||
|
||||
assert response.status_code == 200
|
||||
assert response.get_json() == {
|
||||
"id": account.id,
|
||||
"name": "Test User",
|
||||
"email": account.email,
|
||||
"avatar": "avatar_url",
|
||||
|
||||
@ -3,7 +3,7 @@ from __future__ import annotations
|
||||
from inspect import unwrap
|
||||
from unittest.mock import patch
|
||||
|
||||
from controllers.console.auth.oauth_server import OAuthServerUserAuthorizeApi
|
||||
from controllers.console.auth.oauth_server import OAuthServerUserAccountApi, OAuthServerUserAuthorizeApi
|
||||
from models import Account
|
||||
from models.account import AccountStatus, TenantAccountRole
|
||||
from models.model import OAuthProviderApp
|
||||
@ -45,3 +45,13 @@ def test_oauth_authorize_uses_injected_current_user() -> None:
|
||||
|
||||
sign_oauth_authorization_code.assert_called_once_with("client-1", "account-1")
|
||||
assert response == {"code": "authorization-code"}
|
||||
|
||||
|
||||
def test_oauth_account_returns_stable_account_id() -> None:
|
||||
api = OAuthServerUserAccountApi()
|
||||
method = unwrap(api.post)
|
||||
account = _make_account()
|
||||
|
||||
response = method(api, _make_oauth_provider_app(), account)
|
||||
|
||||
assert response["id"] == "account-1"
|
||||
|
||||
@ -40,6 +40,7 @@ export type OAuthClientPayload = {
|
||||
export type OAuthProviderAccountResponse = {
|
||||
avatar?: string | null
|
||||
email: string
|
||||
id: string
|
||||
interface_language: string
|
||||
name: string
|
||||
timezone: string
|
||||
|
||||
@ -60,6 +60,7 @@ export const zOAuthClientPayload = z.object({
|
||||
export const zOAuthProviderAccountResponse = z.object({
|
||||
avatar: z.string().nullish(),
|
||||
email: z.string(),
|
||||
id: z.string(),
|
||||
interface_language: z.string(),
|
||||
name: z.string(),
|
||||
timezone: z.string(),
|
||||
|
||||
Loading…
Reference in New Issue
Block a user