diff --git a/.changeset/smart-melons-shop.md b/.changeset/smart-melons-shop.md new file mode 100644 index 00000000000..e998cdef549 --- /dev/null +++ b/.changeset/smart-melons-shop.md @@ -0,0 +1,10 @@ +--- +"@logto/phrases": patch +"@logto/core": patch +--- + +Fix file upload API. + +The `koa-body` has been upgraded to the latest version, which caused the file upload API to break. This change fixes the issue. + +The `ctx.request.files.file` in the new version is an array, so the code has been updated to pick the first one. diff --git a/packages/connectors/connector-feishu-web/src/index.ts b/packages/connectors/connector-feishu-web/src/index.ts index a2b25b2f929..56ed8cccc99 100644 --- a/packages/connectors/connector-feishu-web/src/index.ts +++ b/packages/connectors/connector-feishu-web/src/index.ts @@ -153,7 +153,7 @@ export function getUserInfo(getConfig: GetConnectorConfig): GetUserInfo { avatar, email: conditional(email), userId: conditional(user_id), - phone: conditional(mobile), + phone: conditional(mobile?.replace('+', '')), rawData: jsonGuard.parse(response.body), }; } catch (error: unknown) { diff --git a/packages/core/src/routes/user-assets.ts b/packages/core/src/routes/user-assets.ts index 9eb0c054597..19c155bccb1 100644 --- a/packages/core/src/routes/user-assets.ts +++ b/packages/core/src/routes/user-assets.ts @@ -52,13 +52,15 @@ export default function userAssetsRoutes( '/user-assets', koaGuard({ files: object({ - file: uploadFileGuard, + file: uploadFileGuard.array().min(1), }), response: userAssetsGuard, }), async (ctx, next) => { - const { file } = ctx.guard.files; + const { file: bodyFiles } = ctx.guard.files; + const file = bodyFiles[0]; + assertThat(file, 'guard.invalid_input'); assertThat(file.size <= maxUploadFileSize, 'guard.file_size_exceeded'); assertThat( allowUploadMimeTypes.map(String).includes(file.mimetype),