fix(fe/state_updater): initAll always returns error for unauthed users

This commit is contained in:
hexxa 2021-12-21 11:10:24 +08:00 committed by Hexxa
parent df801a9397
commit 87832ee1b2
2 changed files with 22 additions and 9 deletions

View file

@ -541,7 +541,7 @@ export class FilesPanel extends React.Component<Props, State, {}> {
<span onClick={() => this.select(item.name)} className="float-l">
{isSelected
? getIcon("RiCheckboxFill", "1.8rem", "cyan0")
: getIcon("RiCheckboxBlankFill", "1.8rem", "grey1")}
: getIcon("RiCheckboxBlankFill", "1.8rem", "black1")}
</span>
</div>
) : (
@ -550,13 +550,13 @@ export class FilesPanel extends React.Component<Props, State, {}> {
onClick={() => this.toggleDetail(item.name)}
className="float-l"
>
{getIcon("RiInformationFill", "1.8rem", "grey1")}
{getIcon("RiInformationFill", "1.8rem", "black1")}
</span>
<span onClick={() => this.select(item.name)} className="float-l">
{isSelected
? getIcon("RiCheckboxFill", "1.8rem", "cyan0")
: getIcon("RiCheckboxBlankFill", "1.8rem", "grey1")}
: getIcon("RiCheckboxBlankFill", "1.8rem", "black1")}
</span>
</div>
);

View file

@ -413,8 +413,11 @@ export class Updater {
syncCwd = async (): Promise<string> => {
if (this.props.filesInfo.dirPath.size !== 0) {
return this.setItems(this.props.filesInfo.dirPath);
} else if (this.props.login.authed) {
return this.setHomeItems();
}
return this.setHomeItems();
// cwd will not be synced if the user is not authned and without sharing mode
return "";
};
initCwd = async (params: URLSearchParams): Promise<string> => {
@ -445,18 +448,26 @@ export class Updater {
return isAuthedStatus;
}
const getCapStatus = await this.getCaptchaID();
if (getCapStatus !== "") {
return getCapStatus;
}
const selfStatuses = await Promise.all([this.self(), this.initCwd(params)]);
if (selfStatuses.join("") !== "") {
return selfStatuses.join(";");
}
const getCapStatus = await this.getCaptchaID();
if (getCapStatus !== "") {
return getCapStatus;
}
this.initUITree();
const isInSharingMode = this.props.ui.control.controls.get(sharingCtrl);
if (
this.props.login.userRole === roleVisitor &&
isInSharingMode !== ctrlOn
) {
return this.initStateForVisitor();
}
const cwdStatus = await this.syncCwd();
if (cwdStatus !== "") {
return cwdStatus;
@ -472,6 +483,7 @@ export class Updater {
if (this.props.login.userRole === roleAdmin) {
return this.initStateForAdmin();
} else if (this.props.login.userRole === roleVisitor) {
// visitor under sharing mode
return this.initStateForVisitor();
}
return this.initStateForAuthedUser();
@ -514,6 +526,7 @@ export class Updater {
this.props.login.preferences = resp.data.preferences;
return "";
} else if (resp.status === 401) {
this.resetUser();
return "";
}