Compare commits

...

6 Commits

Author SHA1 Message Date
Jiawei Chen
0bda29f143 feat: show 404 error for non-existent objects in edit pages 2023-06-10 01:56:15 +08:00
Yang Luo
05703720c5 Add Custom to resourceType 2023-06-09 21:52:30 +08:00
hsluoyz
cc566bf31f Move DoMigration() after CreateTables() 2023-06-09 09:36:20 +08:00
XDTD
e93d8c19d9 feat: resolve user pages malfunction after using tableNamePrefix (#1945) 2023-06-08 00:43:05 +08:00
Yang Luo
f2e3182a69 Fix null value in backend Translate() 2023-06-07 02:17:48 +08:00
Yang Luo
f934531083 Fix organization search in some pages 2023-06-06 20:53:45 +08:00
26 changed files with 111 additions and 13 deletions

View File

@@ -108,10 +108,10 @@ func GetLanguage(language string) string {
return "en"
}
if len(language) < 2 {
if len(language) != 2 {
return "en"
} else {
return language[0:2]
return language
}
}

View File

@@ -31,12 +31,12 @@ import (
)
func main() {
createDatabase := flag.Bool("createDatabase", false, "true if you need Casdoor to create database")
createDatabase := *flag.Bool("createDatabase", false, "true if you need Casdoor to create database")
flag.Parse()
object.InitAdapter()
object.CreateTables(createDatabase)
object.DoMigration()
object.CreateTables(*createDatabase)
object.InitDb()
object.InitFromFile()

View File

@@ -41,8 +41,8 @@ func InitConfig() {
beego.BConfig.WebConfig.Session.SessionOn = true
InitAdapter()
DoMigration()
CreateTables(true)
DoMigration()
}
func InitAdapter() {
@@ -305,7 +305,8 @@ func GetSessionForUser(owner string, offset, limit int, field, value, sortField,
sortField = "created_time"
}
tableName := "user"
tableNamePrefix := conf.GetConfigString("tableNamePrefix")
tableName := tableNamePrefix + "user"
if offset == -1 {
if sortOrder == "ascend" {
session = session.Asc(util.SnakeString(sortField))

View File

@@ -50,6 +50,11 @@ class AdapterEditPage extends React.Component {
AdapterBackend.getAdapter("admin", this.state.adapterName)
.then((res) => {
if (res.status === "ok") {
if (res.data === null) {
this.props.history.push("/404");
return;
}
this.setState({
adapter: res.data,
});

View File

@@ -119,6 +119,11 @@ class ApplicationEditPage extends React.Component {
getApplication() {
ApplicationBackend.getApplication("admin", this.state.applicationName)
.then((application) => {
if (application === null) {
this.props.history.push("/404");
return;
}
if (application.grantTypes === null || application.grantTypes === undefined || application.grantTypes.length === 0) {
application.grantTypes = ["authorization_code"];
}

View File

@@ -45,6 +45,11 @@ class CertEditPage extends React.Component {
getCert() {
CertBackend.getCert(this.state.owner, this.state.certName)
.then((cert) => {
if (cert === null) {
this.props.history.push("/404");
return;
}
this.setState({
cert: cert,
});

View File

@@ -108,7 +108,7 @@ class CertListPage extends BaseListPage {
key: "owner",
width: "150px",
sorter: true,
...this.getColumnSearchProps("organization"),
...this.getColumnSearchProps("owner"),
render: (text, record, index) => {
return (text !== "admin") ? text : i18next.t("provider:admin (Shared)");
},

View File

@@ -41,6 +41,11 @@ class ChatEditPage extends React.Component {
getChat() {
ChatBackend.getChat("admin", this.state.chatName)
.then((chat) => {
if (chat === null) {
this.props.history.push("/404");
return;
}
this.setState({
chat: chat,
});

View File

@@ -46,6 +46,11 @@ class MessageEditPage extends React.Component {
getMessage() {
MessageBackend.getMessage("admin", this.state.messageName)
.then((message) => {
if (message === null) {
this.props.history.push("/404");
return;
}
this.setState({
message: message,
});

View File

@@ -48,6 +48,11 @@ class ModelEditPage extends React.Component {
getModel() {
ModelBackend.getModel(this.state.organizationName, this.state.modelName)
.then((model) => {
if (model === null) {
this.props.history.push("/404");
return;
}
this.setState({
model: model,
});

View File

@@ -50,6 +50,11 @@ class OrganizationEditPage extends React.Component {
getOrganization() {
OrganizationBackend.getOrganization("admin", this.state.organizationName)
.then((organization) => {
if (organization === null) {
this.props.history.push("/404");
return;
}
this.setState({
organization: organization,
});

View File

@@ -40,8 +40,13 @@ class PaymentEditPage extends React.Component {
}
getPayment() {
PaymentBackend.getPayment(this.props.account.owner, this.state.paymentName)
PaymentBackend.getPayment("admin", this.state.paymentName)
.then((payment) => {
if (payment === null) {
this.props.history.push("/404");
return;
}
this.setState({
payment: payment,
});

View File

@@ -50,6 +50,11 @@ class PermissionEditPage extends React.Component {
getPermission() {
PermissionBackend.getPermission(this.state.organizationName, this.state.permissionName)
.then((permission) => {
if (permission === null) {
this.props.history.push("/404");
return;
}
this.setState({
permission: permission,
});
@@ -264,10 +269,12 @@ class PermissionEditPage extends React.Component {
<Col span={22} >
<Select virtual={false} style={{width: "100%"}} value={this.state.permission.resourceType} onChange={(value => {
this.updatePermissionField("resourceType", value);
this.updatePermissionField("resources", []);
})}
options={[
{value: "Application", name: i18next.t("general:Application")},
{value: "TreeNode", name: i18next.t("permission:TreeNode")},
{value: "Custom", name: i18next.t("general:Custom")},
].map((item) => Setting.getOption(item.name, item.value))}
/>
</Col>
@@ -277,7 +284,7 @@ class PermissionEditPage extends React.Component {
{Setting.getLabel(i18next.t("general:Resources"), i18next.t("permission:Resources - Tooltip"))} :
</Col>
<Col span={22} >
<Select virtual={false} mode="multiple" style={{width: "100%"}} value={this.state.permission.resources}
<Select virtual={false} mode={(this.state.permission.resourceType === "Custom") ? "tags" : "multiple"} style={{width: "100%"}} value={this.state.permission.resources}
onChange={(value => {this.updatePermissionField("resources", value);})}
options={this.state.resources.map((resource) => Setting.getOption(`${resource.name}`, `${resource.name}`))
} />

View File

@@ -47,6 +47,11 @@ class PlanEditPage extends React.Component {
getPlan() {
PlanBackend.getPlan(this.state.organizationName, this.state.planName)
.then((plan) => {
if (plan === null) {
this.props.history.push("/404");
return;
}
this.setState({
plan: plan,
});

View File

@@ -50,6 +50,11 @@ class PricingEditPage extends React.Component {
getPricing() {
PricingBackend.getPricing(this.state.organizationName, this.state.pricingName)
.then((pricing) => {
if (pricing === null) {
this.props.history.push("/404");
return;
}
this.setState({
pricing: pricing,
});

View File

@@ -45,6 +45,11 @@ class ProductEditPage extends React.Component {
getProduct() {
ProductBackend.getProduct(this.props.account.owner, this.state.productName)
.then((product) => {
if (product === null) {
this.props.history.push("/404");
return;
}
this.setState({
product: product,
});

View File

@@ -100,7 +100,7 @@ class ProductListPage extends BaseListPage {
key: "owner",
width: "150px",
sorter: true,
...this.getColumnSearchProps("organization"),
...this.getColumnSearchProps("owner"),
},
{
title: i18next.t("general:Created time"),

View File

@@ -50,6 +50,11 @@ class ProviderEditPage extends React.Component {
getProvider() {
ProviderBackend.getProvider(this.state.owner, this.state.providerName)
.then((res) => {
if (res === null) {
this.props.history.push("/404");
return;
}
if (res.status === "ok") {
this.setState({
provider: res.data,

View File

@@ -111,7 +111,7 @@ class ProviderListPage extends BaseListPage {
key: "owner",
width: "150px",
sorter: true,
...this.getColumnSearchProps("organization"),
...this.getColumnSearchProps("owner"),
render: (text, record, index) => {
return (text !== "admin") ? text : i18next.t("provider:admin (Shared)");
},

View File

@@ -43,6 +43,11 @@ class RoleEditPage extends React.Component {
getRole() {
RoleBackend.getRole(this.state.organizationName, this.state.roleName)
.then((role) => {
if (role === null) {
this.props.history.push("/404");
return;
}
this.setState({
role: role,
});

View File

@@ -55,10 +55,10 @@ class SessionListPage extends BaseListPage {
{
title: i18next.t("general:Organization"),
dataIndex: "owner",
key: "organization",
key: "owner",
width: "110px",
sorter: true,
...this.getColumnSearchProps("organization"),
...this.getColumnSearchProps("owner"),
render: (text, record, index) => {
return (
<Link to={`/organizations/${text}`}>

View File

@@ -47,6 +47,11 @@ class SubscriptionEditPage extends React.Component {
getSubscription() {
SubscriptionBackend.getSubscription(this.state.organizationName, this.state.subscriptionName)
.then((subscription) => {
if (subscription === null) {
this.props.history.push("/404");
return;
}
this.setState({
subscription: subscription,
});

View File

@@ -48,6 +48,11 @@ class SyncerEditPage extends React.Component {
getSyncer() {
SyncerBackend.getSyncer("admin", this.state.syncerName)
.then((syncer) => {
if (syncer === null) {
this.props.history.push("/404");
return;
}
this.setState({
syncer: syncer,
});

View File

@@ -36,6 +36,11 @@ class TokenEditPage extends React.Component {
getToken() {
TokenBackend.getToken("admin", this.state.tokenName)
.then((token) => {
if (token === null) {
this.props.history.push("/404");
return;
}
this.setState({
token: token,
});

View File

@@ -66,6 +66,11 @@ class UserEditPage extends React.Component {
getUser() {
UserBackend.getUser(this.state.organizationName, this.state.userName)
.then((data) => {
if (data === null) {
this.props.history.push("/404");
return;
}
if (data.status === null || data.status !== "error") {
this.setState({
user: data,

View File

@@ -123,6 +123,11 @@ class WebhookEditPage extends React.Component {
getWebhook() {
WebhookBackend.getWebhook("admin", this.state.webhookName)
.then((webhook) => {
if (webhook === null) {
this.props.history.push("/404");
return;
}
this.setState({
webhook: webhook,
});