dream-num / univer

Univer is an open-source alternative to Google Sheets, Slides, and Docs
https://univer.ai
Apache License 2.0
5.73k stars 474 forks source link

[Bug] After the user is set after calling the userManagerService.setCurrentUser method, after the protection is created, the creator displayed is not the set user. #2582

Closed LiuYuLu closed 1 week ago

LiuYuLu commented 2 weeks ago

在您提交此问题之前,您是否检查了以下内容?

受影响的包和版本

0.1.15

复现链接

https://stackblitz.com/~/github.com/awesome-univer/sheets-permission-demo

image

预期行为

setCurrentUser方法调用后,操作记录的人应该是设置中的人

实际行为

调用userManagerService.setCurrentUser方法后设置的用户,创建保护后,显示的创建人不是设置的用户

运行环境

其他 (请在复现步骤中说明)

系统信息

No response

univer-bot[bot] commented 2 weeks ago

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿

Origin Title: [Bug] 调用userManagerService.setCurrentUser方法后设置的用户,创建保护后,显示的创建人不是设置的用户

Title: [Bug] After the user is set after calling the userManagerService.setCurrentUser method, after the protection is created, the creator displayed is not the set user.


Before you submitted this question, did you check the following?

Affected packages and versions

0.1.15

Recurrence link

https://stackblitz.com/~/github.com/awesome-univer/sheets-permission-demo

image

Expected behavior

After the setCurrentUser method is called, the person operating the record should be the person in the setting

Actual behavior

The user set after calling the userManagerService.setCurrentUser method. After the protection is created, the creator displayed is not the set user.

Running environment

Others (please explain in the reproduction steps)

system message

No response

Gggpound commented 1 week ago
image

改造 2 个地方试试这样. 第一个地方,我们在mock权限体系的时候,通过在userID 中注入特别的字符来标明身份

image

第二个地方,在mock权限io的时候,会设置用户身份,你得确保你设置的mockUser的时序在这个之后。

image

所以你需要提前injector.get,来触发 AuthzIoLocalService 的实例化(这部分实例化逻辑是交给di框架的,如果没有手动get,那么实例化的时机会在你创建区域保护规则的时候执行.)

univer-bot[bot] commented 1 week ago

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿

image

Try this to remodel 2 places. First, when we mock the permission system, we indicate the identity by injecting special characters into the userID.

image

The second place is that when mocking permission io, the user identity will be set. You have to make sure that the timing of the mockUser you set is after this.

image

So you need to injector.get in advance to trigger the instantiation of AuthzIoLocalService (this part of the instantiation logic is handed over to the di framework. If there is no manual get, the instantiation will be executed when you create the regional protection rule.)