mirror of
https://github.com/casdoor/casdoor.git
synced 2025-05-23 02:35:49 +08:00
feat: response with status in casbin_adapter.go
(#1384)
* fix: response standardized information with status in `casbin_adapter.go` * fix: remove redundant statements
This commit is contained in:
parent
2bb2c36f22
commit
e705eecffe
@ -32,8 +32,8 @@ func (c *ApiController) GetCasbinAdapters() {
|
||||
sortField := c.Input().Get("sortField")
|
||||
sortOrder := c.Input().Get("sortOrder")
|
||||
if limit == "" || page == "" {
|
||||
c.Data["json"] = object.GetCasbinAdapters(owner)
|
||||
c.ServeJSON()
|
||||
adapters := object.GetCasbinAdapters(owner)
|
||||
c.ResponseOk(adapters)
|
||||
} else {
|
||||
limit := util.ParseInt(limit)
|
||||
paginator := pagination.SetPaginator(c.Ctx, limit, int64(object.GetCasbinAdapterCount(owner, field, value)))
|
||||
@ -44,8 +44,8 @@ func (c *ApiController) GetCasbinAdapters() {
|
||||
|
||||
func (c *ApiController) GetCasbinAdapter() {
|
||||
id := c.Input().Get("id")
|
||||
c.Data["json"] = object.GetCasbinAdapter(id)
|
||||
c.ServeJSON()
|
||||
adapter := object.GetCasbinAdapter(id)
|
||||
c.ResponseOk(adapter)
|
||||
}
|
||||
|
||||
func (c *ApiController) UpdateCasbinAdapter() {
|
||||
@ -96,8 +96,7 @@ func (c *ApiController) SyncPolicies() {
|
||||
return
|
||||
}
|
||||
|
||||
c.Data["json"] = policies
|
||||
c.ServeJSON()
|
||||
c.ResponseOk(policies)
|
||||
}
|
||||
|
||||
func (c *ApiController) UpdatePolicy() {
|
||||
|
@ -48,12 +48,14 @@ class AdapterEditPage extends React.Component {
|
||||
|
||||
getAdapter() {
|
||||
AdapterBackend.getAdapter(this.state.owner, this.state.adapterName)
|
||||
.then((adapter) => {
|
||||
this.setState({
|
||||
adapter: adapter,
|
||||
});
|
||||
.then((res) => {
|
||||
if (res.status === "ok") {
|
||||
this.setState({
|
||||
adapter: res.data,
|
||||
});
|
||||
|
||||
this.getModels(adapter.owner);
|
||||
this.getModels(this.adapter.owner);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -91,7 +91,7 @@ class PolicyTable extends React.Component {
|
||||
AdapterBackend.syncPolicies(this.props.owner, this.props.name)
|
||||
.then((res) => {
|
||||
if (res.status === "ok") {
|
||||
this.setState({policyLists: res});
|
||||
this.setState({policyLists: res.data});
|
||||
} else {
|
||||
Setting.showMessage("error", `${i18next.t("adapter:Failed to sync policies")}: ${res.msg}`);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user