Skip to content

Commit

Permalink
fix: remove the plus sign in front of the phone number (#5801)
Browse files Browse the repository at this point in the history
  • Loading branch information
kamto7 authored and wangsijie committed Apr 30, 2024
1 parent 24acae8 commit 633a9a3
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
10 changes: 10 additions & 0 deletions .changeset/smart-melons-shop.md
Original file line number Diff line number Diff line change
@@ -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.
2 changes: 1 addition & 1 deletion packages/connectors/connector-feishu-web/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
6 changes: 4 additions & 2 deletions packages/core/src/routes/user-assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,15 @@ export default function userAssetsRoutes<T extends ManagementApiRouter>(
'/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;

Check warning on line 60 in packages/core/src/routes/user-assets.ts

View check run for this annotation

Codecov / codecov/patch

packages/core/src/routes/user-assets.ts#L60

Added line #L60 was not covered by tests

const file = bodyFiles[0];
assertThat(file, 'guard.invalid_input');

Check warning on line 63 in packages/core/src/routes/user-assets.ts

View check run for this annotation

Codecov / codecov/patch

packages/core/src/routes/user-assets.ts#L62-L63

Added lines #L62 - L63 were not covered by tests
assertThat(file.size <= maxUploadFileSize, 'guard.file_size_exceeded');
assertThat(
allowUploadMimeTypes.map(String).includes(file.mimetype),
Expand Down

0 comments on commit 633a9a3

Please sign in to comment.