Merge branch 'main' into next

This commit is contained in:
chenos 2024-12-08 14:00:12 +08:00
commit 6e8d7edc7d
5 changed files with 71 additions and 3 deletions

View File

@ -5,6 +5,33 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [v1.4.4](https://github.com/nocobase/nocobase/compare/v1.4.3...v1.4.4) - 2024-12-08
### 🐛 Bug Fixes
- **[client]**
- Fix issue with external data source fields not display in table block ([#5825](https://github.com/nocobase/nocobase/pull/5825)) by @katherinehhh
- Fix display issue for inherited fields in form configuration ([#5822](https://github.com/nocobase/nocobase/pull/5822)) by @katherinehhh
- Fix inherited fields not appear in field list and cannot override ([#5800](https://github.com/nocobase/nocobase/pull/5800)) by @katherinehhh
- **[Data visualization]** Fix the issue when formatting timezone-aware date fields in MySQL ([#5829](https://github.com/nocobase/nocobase/pull/5829)) by @2013xile
- **[Workflow]**
- Fix transaction across data sources which cause collection event error ([#5818](https://github.com/nocobase/nocobase/pull/5818)) by @mytharcher
- Fix date type missed in date field based schedule configuration ([#5816](https://github.com/nocobase/nocobase/pull/5816)) by @mytharcher
- **[Collection field: Many to many (array)]** Fix the issue where updating m2m array fields in single relation collection does not take effect ([#5820](https://github.com/nocobase/nocobase/pull/5820)) by @2013xile
- **[Calendar]**
- Fix error when clicking on a blank date in the calendar ([#5803](https://github.com/nocobase/nocobase/pull/5803)) by @katherinehhh
- Fix the issue where closing a popup opened through the 'Calendar Block' causes all popups to close ([#5793](https://github.com/nocobase/nocobase/pull/5793)) by @zhangzhonghe
- **[Public forms]** Fix incorrect QC code scan path in sub-application public form ([#5799](https://github.com/nocobase/nocobase/pull/5799)) by @katherinehhh
## [v1.4.3](https://github.com/nocobase/nocobase/compare/v1.4.2...v1.4.3) - 2024-12-05
### 🚀 Improvements

View File

@ -5,6 +5,33 @@
格式基于 [Keep a Changelog](https://keepachangelog.com/zh-CN/1.0.0/),
并且本项目遵循 [语义化版本](https://semver.org/spec/v2.0.0.html)。
## [v1.4.4](https://github.com/nocobase/nocobase/compare/v1.4.3...v1.4.4) - 2024-12-08
### 🐛 修复
- **[client]**
- 修复表格区块中外部数据源字段列表没有显示 ([#5825](https://github.com/nocobase/nocobase/pull/5825)) by @katherinehhh
- 修复表单配置字段继承字段的显示问题 ([#5822](https://github.com/nocobase/nocobase/pull/5822)) by @katherinehhh
- 修复表继承缺陷:字段列表未显示继承表字段且在数据表中无法重写继承字段 ([#5800](https://github.com/nocobase/nocobase/pull/5800)) by @katherinehhh
- **[数据可视化]** 修复在 MySQL 中格式化带时区的日期字段的问题 ([#5829](https://github.com/nocobase/nocobase/pull/5829)) by @2013xile
- **[工作流]**
- 修复由于事务引起的外部数据源数据表同步事件触发错误 ([#5818](https://github.com/nocobase/nocobase/pull/5818)) by @mytharcher
- 修复定时任务时间字段配置中缺少的日期类型 ([#5816](https://github.com/nocobase/nocobase/pull/5816)) by @mytharcher
- **[数据表字段:多对多 (数组)]** 修复更新对一关联表中多对多(数组)字段不生效的问题 ([#5820](https://github.com/nocobase/nocobase/pull/5820)) by @2013xile
- **[日历]**
- 修复日历点击空白日期时报错的问题 ([#5803](https://github.com/nocobase/nocobase/pull/5803)) by @katherinehhh
- 修复关闭通过“日历区块”打开的弹窗,导致所有弹窗都关闭的问题 ([#5793](https://github.com/nocobase/nocobase/pull/5793)) by @zhangzhonghe
- **[公开表单]** 修复子应用中公开表 QC code 扫码打开路径不正确 ([#5799](https://github.com/nocobase/nocobase/pull/5799)) by @katherinehhh
## [v1.4.3](https://github.com/nocobase/nocobase/compare/v1.4.2...v1.4.3) - 2024-12-05
### 🚀 优化

View File

@ -109,10 +109,15 @@ export class APIClient extends APIClientSDK {
// TODO(yangqia): improve error code and message
if (errs.find((error: { code?: string }) => error.code === 'ROLE_NOT_FOUND_ERR')) {
this.auth.setRole(null);
window.location.reload();
}
if (errs.find((error: { code?: string }) => error.code === 'TOKEN_INVALID')) {
this.auth.setToken(null);
}
if (errs.find((error: { code?: string }) => error.code === 'ROLE_NOT_FOUND_FOR_USER')) {
this.auth.setRole(null);
window.location.reload();
}
throw error;
},
);

View File

@ -7,10 +7,10 @@
* For more information, please refer to: https://www.nocobase.com/agreement.
*/
import { vi } from 'vitest';
import Database from '@nocobase/database';
import UsersPlugin from '@nocobase/plugin-users';
import { MockServer } from '@nocobase/test';
import { vi } from 'vitest';
import { setCurrentRole } from '../middlewares/setCurrentRole';
import { prepareApp } from './prepare';
@ -67,7 +67,7 @@ describe('role', () => {
expect(ctx.state.currentRole).toBe('root');
});
it('should use default role when the role does not belong to the user', async () => {
it('should throw error', async () => {
ctx.state.currentUser = await db.getRepository('users').findOne({
appends: ['roles'],
});
@ -79,7 +79,10 @@ describe('role', () => {
const throwFn = vi.fn();
ctx.throw = throwFn;
await setCurrentRole(ctx, () => {});
expect(ctx.state.currentRole).toBe('root');
expect(throwFn).lastCalledWith(401, {
code: 'ROLE_NOT_FOUND_FOR_USER',
message: 'The role does not belong to the user',
});
});
it('should set role with anonymous', async () => {

View File

@ -50,6 +50,12 @@ export async function setCurrentRole(ctx: Context, next) {
// 1. If the X-Role is set, use the specified role
if (currentRole) {
role = userRoles.find((role) => role.name === currentRole)?.name;
if (!role) {
return ctx.throw(401, {
code: 'ROLE_NOT_FOUND_FOR_USER',
message: ctx.t('The role does not belong to the user', { ns: 'acl' }),
});
}
}
// 2. If the X-Role is not set, or the X-Role does not belong to the user, use the default role
if (!role) {