Skip to content

Commit

Permalink
fix(web): fix the bug of infinity loop animate when unauthorized (cas…
Browse files Browse the repository at this point in the history
…door#891)

* fix(web): fix the bug of infinity loop when unauthorized

* fix

* fix

* fix

* Update BaseListPage.js

* Update OrganizationListPage.js

* Update OrganizationListPage.js

Co-authored-by: Yang Luo <[email protected]>
  • Loading branch information
qianxi0410 and hsluoyz authored Jul 17, 2022
1 parent a0b0e18 commit 1fff1db
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 1 deletion.
1 change: 1 addition & 0 deletions web/src/BaseListPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class BaseListPage extends React.Component {
loading: false,
searchText: "",
searchedColumn: "",
isAuthorized: true,
};
}

Expand Down
20 changes: 19 additions & 1 deletion web/src/OrganizationListPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

import React from "react";
import {Link} from "react-router-dom";
import {Button, Popconfirm, Switch, Table} from "antd";
import {Button, Popconfirm, Result, Switch, Table} from "antd";
import moment from "moment";
import * as Setting from "./Setting";
import * as OrganizationBackend from "./backend/OrganizationBackend";
Expand Down Expand Up @@ -235,6 +235,17 @@ class OrganizationListPage extends BaseListPage {
showTotal: () => i18next.t("general:{total} in total").replace("{total}", this.state.pagination.total),
};

if (!this.state.isAuthorized) {
return (
<Result
status="403"
title="403 Unauthorized"
subTitle={i18next.t("general:Sorry, you do not have permission to access this page.")}
extra={<a href="/"><Button type="primary">{i18next.t("general:Back Home")}</Button></a>}
/>
);
}

return (
<div>
<Table scroll={{x: "max-content"}} columns={columns} dataSource={organizations} rowKey="name" size="middle" bordered pagination={paginationProps}
Expand Down Expand Up @@ -272,6 +283,13 @@ class OrganizationListPage extends BaseListPage {
searchText: params.searchText,
searchedColumn: params.searchedColumn,
});
} else {
if (res.msg.includes("Unauthorized")) {
this.setState({
loading: false,
isAuthorized: false,
});
}
}
});
};
Expand Down
1 change: 1 addition & 0 deletions web/src/locales/de/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@
"Signup application - Tooltip": "Signup application - Tooltip",
"Sorry, the page you visited does not exist.": "Die von Ihnen besuchte Seite existiert leider nicht.",
"Sorry, the user you visited does not exist or you are not authorized to access this user.": "Sorry, the user you visited does not exist or you are not authorized to access this user.",
"Sorry, you do not have permission to access this page.": "Sorry, you do not have permission to access this page.",
"State": "State",
"State - Tooltip": "State - Tooltip",
"Swagger": "Swagger",
Expand Down
1 change: 1 addition & 0 deletions web/src/locales/en/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@
"Signup application - Tooltip": "Signup application - Tooltip",
"Sorry, the page you visited does not exist.": "Sorry, the page you visited does not exist.",
"Sorry, the user you visited does not exist or you are not authorized to access this user.": "Sorry, the user you visited does not exist or you are not authorized to access this user.",
"Sorry, you do not have permission to access this page.": "Sorry, you do not have permission to access this page.",
"State": "State",
"State - Tooltip": "State - Tooltip",
"Swagger": "Swagger",
Expand Down
1 change: 1 addition & 0 deletions web/src/locales/fr/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@
"Signup application - Tooltip": "Signup application - Tooltip",
"Sorry, the page you visited does not exist.": "Désolé, la page que vous avez visitée n'existe pas.",
"Sorry, the user you visited does not exist or you are not authorized to access this user.": "Sorry, the user you visited does not exist or you are not authorized to access this user.",
"Sorry, you do not have permission to access this page.": "Désolé, vous n'avez pas la permission d'accéder à cette page.",
"State": "State",
"State - Tooltip": "State - Tooltip",
"Swagger": "Swagger",
Expand Down
1 change: 1 addition & 0 deletions web/src/locales/ja/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@
"Signup application - Tooltip": "Signup application - Tooltip",
"Sorry, the page you visited does not exist.": "申し訳ありませんが、訪問したページは存在しません。",
"Sorry, the user you visited does not exist or you are not authorized to access this user.": "Sorry, the user you visited does not exist or you are not authorized to access this user.",
"Sorry, you do not have permission to access this page.": "申し訳ありませんが、このページにアクセスする権限がありません。",
"State": "State",
"State - Tooltip": "State - Tooltip",
"Swagger": "Swagger",
Expand Down
1 change: 1 addition & 0 deletions web/src/locales/ko/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@
"Signup application - Tooltip": "Signup application - Tooltip",
"Sorry, the page you visited does not exist.": "Sorry, the page you visited does not exist.",
"Sorry, the user you visited does not exist or you are not authorized to access this user.": "Sorry, the user you visited does not exist or you are not authorized to access this user.",
"Sorry, you do not have permission to access this page.": "Sorry, you do not have permission to access this page.",
"State": "State",
"State - Tooltip": "State - Tooltip",
"Swagger": "Swagger",
Expand Down
1 change: 1 addition & 0 deletions web/src/locales/ru/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@
"Signup application - Tooltip": "Signup application - Tooltip",
"Sorry, the page you visited does not exist.": "Извините, посещенная вами страница не существует.",
"Sorry, the user you visited does not exist or you are not authorized to access this user.": "Sorry, the user you visited does not exist or you are not authorized to access this user.",
"Sorry, you do not have permission to access this page.": "Извините, вы не имеете права доступа к этой странице.",
"State": "State",
"State - Tooltip": "State - Tooltip",
"Swagger": "Swagger",
Expand Down
1 change: 1 addition & 0 deletions web/src/locales/zh/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@
"Signup application - Tooltip": "表示用户注册时通过哪个应用注册的",
"Sorry, the page you visited does not exist.": "抱歉,您访问的页面不存在",
"Sorry, the user you visited does not exist or you are not authorized to access this user.": "抱歉,您访问的用户不存在或您无权访问该用户",
"Sorry, you do not have permission to access this page.": "抱歉,您无权访问该页面",
"State": "状态",
"State - Tooltip": "状态",
"Swagger": "API文档",
Expand Down

0 comments on commit 1fff1db

Please sign in to comment.