mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-04 05:10:19 +08:00
Fix property empty issue
This commit is contained in:
@ -361,6 +361,9 @@ func (c *ApiController) UploadResource() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if user.Properties == nil {
|
||||||
|
user.Properties = map[string]string{}
|
||||||
|
}
|
||||||
user.Properties[tag] = fileUrl
|
user.Properties[tag] = fileUrl
|
||||||
user.Properties["isIdCardVerified"] = "false"
|
user.Properties["isIdCardVerified"] = "false"
|
||||||
_, err = object.UpdateUser(user.GetId(), user, []string{"properties"}, false)
|
_, err = object.UpdateUser(user.GetId(), user, []string{"properties"}, false)
|
||||||
|
@ -309,8 +309,7 @@ func GetAllRoles(userId string) []string {
|
|||||||
|
|
||||||
func GetBuiltInModel(modelText string) (model.Model, error) {
|
func GetBuiltInModel(modelText string) (model.Model, error) {
|
||||||
if modelText == "" {
|
if modelText == "" {
|
||||||
modelText = `
|
modelText = `[request_definition]
|
||||||
[request_definition]
|
|
||||||
r = sub, obj, act
|
r = sub, obj, act
|
||||||
|
|
||||||
[policy_definition]
|
[policy_definition]
|
||||||
|
@ -169,7 +169,7 @@ class EnforcerEditPage extends React.Component {
|
|||||||
<Select virtual={false} disabled={Setting.builtInObject(this.state.enforcer)} style={{width: "100%"}} value={this.state.enforcer.model} onChange={(model => {
|
<Select virtual={false} disabled={Setting.builtInObject(this.state.enforcer)} style={{width: "100%"}} value={this.state.enforcer.model} onChange={(model => {
|
||||||
this.updateEnforcerField("model", model);
|
this.updateEnforcerField("model", model);
|
||||||
})}
|
})}
|
||||||
options={this.state.models.map((model) => Setting.getOption(model.displayName, `${model.owner}/${model.name}`))
|
options={this.state.models.map((model) => Setting.getOption(`${model.owner}/${model.name}`, `${model.owner}/${model.name}`))
|
||||||
} />
|
} />
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
@ -181,7 +181,7 @@ class EnforcerEditPage extends React.Component {
|
|||||||
<Select virtual={false} disabled={Setting.builtInObject(this.state.enforcer)} style={{width: "100%"}} value={this.state.enforcer.adapter} onChange={(adapter => {
|
<Select virtual={false} disabled={Setting.builtInObject(this.state.enforcer)} style={{width: "100%"}} value={this.state.enforcer.adapter} onChange={(adapter => {
|
||||||
this.updateEnforcerField("adapter", adapter);
|
this.updateEnforcerField("adapter", adapter);
|
||||||
})}
|
})}
|
||||||
options={this.state.adapters.map((adapter) => Setting.getOption(adapter.name, `${adapter.owner}/${adapter.name}`))
|
options={this.state.adapters.map((adapter) => Setting.getOption(`${adapter.owner}/${adapter.name}`, `${adapter.owner}/${adapter.name}`))
|
||||||
} />
|
} />
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
|
@ -75,7 +75,7 @@ class EnforcerListPage extends BaseListPage {
|
|||||||
title: i18next.t("general:Name"),
|
title: i18next.t("general:Name"),
|
||||||
dataIndex: "name",
|
dataIndex: "name",
|
||||||
key: "name",
|
key: "name",
|
||||||
width: "150px",
|
width: "200px",
|
||||||
fixed: "left",
|
fixed: "left",
|
||||||
sorter: true,
|
sorter: true,
|
||||||
...this.getColumnSearchProps("name"),
|
...this.getColumnSearchProps("name"),
|
||||||
@ -116,10 +116,42 @@ class EnforcerListPage extends BaseListPage {
|
|||||||
title: i18next.t("general:Display name"),
|
title: i18next.t("general:Display name"),
|
||||||
dataIndex: "displayName",
|
dataIndex: "displayName",
|
||||||
key: "displayName",
|
key: "displayName",
|
||||||
width: "200px",
|
// width: "200px",
|
||||||
sorter: true,
|
sorter: true,
|
||||||
...this.getColumnSearchProps("displayName"),
|
...this.getColumnSearchProps("displayName"),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
title: i18next.t("general:Model"),
|
||||||
|
dataIndex: "model",
|
||||||
|
key: "model",
|
||||||
|
width: "250px",
|
||||||
|
fixed: "left",
|
||||||
|
sorter: true,
|
||||||
|
...this.getColumnSearchProps("name"),
|
||||||
|
render: (text, record, index) => {
|
||||||
|
return (
|
||||||
|
<Link to={`/models/${text}`}>
|
||||||
|
{text}
|
||||||
|
</Link>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: i18next.t("general:Adapter"),
|
||||||
|
dataIndex: "adapter",
|
||||||
|
key: "adapter",
|
||||||
|
width: "250px",
|
||||||
|
fixed: "left",
|
||||||
|
sorter: true,
|
||||||
|
...this.getColumnSearchProps("name"),
|
||||||
|
render: (text, record, index) => {
|
||||||
|
return (
|
||||||
|
<Link to={`/adapters/${text}`}>
|
||||||
|
{text}
|
||||||
|
</Link>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
title: i18next.t("general:Is enabled"),
|
title: i18next.t("general:Is enabled"),
|
||||||
dataIndex: "isEnabled",
|
dataIndex: "isEnabled",
|
||||||
@ -136,7 +168,7 @@ class EnforcerListPage extends BaseListPage {
|
|||||||
title: i18next.t("general:Action"),
|
title: i18next.t("general:Action"),
|
||||||
dataIndex: "",
|
dataIndex: "",
|
||||||
key: "op",
|
key: "op",
|
||||||
width: "170px",
|
width: "180px",
|
||||||
fixed: (Setting.isMobile()) ? "false" : "right",
|
fixed: (Setting.isMobile()) ? "false" : "right",
|
||||||
render: (text, record, index) => {
|
render: (text, record, index) => {
|
||||||
return (
|
return (
|
||||||
|
@ -570,7 +570,7 @@ class UserEditPage extends React.Component {
|
|||||||
{name: "ID card back", value: "idCardBack"},
|
{name: "ID card back", value: "idCardBack"},
|
||||||
{name: "ID card with person", value: "idCardWithPerson"},
|
{name: "ID card with person", value: "idCardWithPerson"},
|
||||||
].map((entry) => {
|
].map((entry) => {
|
||||||
return this.renderImage(this.state.user.properties[entry.value] || "", this.getIdCardType(entry.name), this.getIdCardText(entry.name), entry.value, disabled);
|
return this.renderImage(this.state.user.properties === null ? "" : (this.state.user.properties[entry.value] || ""), this.getIdCardType(entry.name), this.getIdCardText(entry.name), entry.value, disabled);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
</Row>
|
</Row>
|
||||||
@ -995,11 +995,13 @@ class UserEditPage extends React.Component {
|
|||||||
<Col span={4} style={{textAlign: "center", margin: "auto"}} key={tag}>
|
<Col span={4} style={{textAlign: "center", margin: "auto"}} key={tag}>
|
||||||
{
|
{
|
||||||
imgUrl ?
|
imgUrl ?
|
||||||
<a target="_blank" rel="noreferrer" href={imgUrl} style={{marginBottom: "10px"}}>
|
<div style={{marginBottom: "10px"}}>
|
||||||
<AccountAvatar src={imgUrl} alt={imgUrl} size={90} style={{marginBottom: "20px"}} />
|
<a target="_blank" rel="noreferrer" href={imgUrl} style={{marginBottom: "10px"}}>
|
||||||
</a>
|
<AccountAvatar src={imgUrl} alt={imgUrl} height={150} />
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
:
|
:
|
||||||
<Col style={{height: "78%", border: "1px dotted grey", borderRadius: 3, marginBottom: 5}}>
|
<Col style={{height: "78%", border: "1px dotted grey", borderRadius: 3, marginBottom: "10px"}}>
|
||||||
<div style={{fontSize: 30, margin: 10}}>+</div>
|
<div style={{fontSize: 30, margin: 10}}>+</div>
|
||||||
<div style={{verticalAlign: "middle", marginBottom: 10}}>{`Upload ${title}...`}</div>
|
<div style={{verticalAlign: "middle", marginBottom: 10}}>{`Upload ${title}...`}</div>
|
||||||
</Col>
|
</Col>
|
||||||
|
@ -17,7 +17,7 @@ import {MetaMaskAvatar} from "react-metamask-avatar";
|
|||||||
|
|
||||||
class AccountAvatar extends React.Component {
|
class AccountAvatar extends React.Component {
|
||||||
render() {
|
render() {
|
||||||
const {src, size} = this.props;
|
const {src, size, width, height} = this.props;
|
||||||
// The avatar for Metamask account is directly generated by an algorithm based on the address
|
// The avatar for Metamask account is directly generated by an algorithm based on the address
|
||||||
// src = "metamask:0xC304b2cC0Be8E9ce10fF3Afd34820Ed306A23600";
|
// src = "metamask:0xC304b2cC0Be8E9ce10fF3Afd34820Ed306A23600";
|
||||||
const matchMetaMask = src.match(/^metamask:(\w+)$/);
|
const matchMetaMask = src.match(/^metamask:(\w+)$/);
|
||||||
@ -27,9 +27,19 @@ class AccountAvatar extends React.Component {
|
|||||||
<MetaMaskAvatar address={address} size={size} />
|
<MetaMaskAvatar address={address} size={size} />
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return (
|
if (size !== undefined) {
|
||||||
<img width={size} height={size} src={src} />
|
return (
|
||||||
);
|
<img width={size} height={size} src={src} />
|
||||||
|
);
|
||||||
|
} else if (width === undefined) {
|
||||||
|
return (
|
||||||
|
<img height={height} src={src} />
|
||||||
|
);
|
||||||
|
} else if (height === undefined) {
|
||||||
|
return (
|
||||||
|
<img width={width} src={src} />
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,11 +33,11 @@ class PolicyTable extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
count = 0;
|
count = 0;
|
||||||
pageSize = 10;
|
pageSize = 100;
|
||||||
|
|
||||||
getIndex(index) {
|
getIndex(index) {
|
||||||
// Need to be used in all place when modify table. Parameter is the row index in table, need to calculate the index in dataSource.
|
// Need to be used in all place when modify table. Parameter is the row index in table, need to calculate the index in dataSource.
|
||||||
return index + (this.state.page - 1) * 10;
|
return index + (this.state.page - 1) * this.pageSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
UNSAFE_componentWillMount() {
|
UNSAFE_componentWillMount() {
|
||||||
@ -165,7 +165,7 @@ class PolicyTable extends React.Component {
|
|||||||
renderTable(table) {
|
renderTable(table) {
|
||||||
const columns = [
|
const columns = [
|
||||||
{
|
{
|
||||||
title: "Rule Type",
|
title: i18next.t("adapter:Rule type"),
|
||||||
dataIndex: "Ptype",
|
dataIndex: "Ptype",
|
||||||
width: "100px",
|
width: "100px",
|
||||||
// render: (text, record, index) => {
|
// render: (text, record, index) => {
|
||||||
@ -270,8 +270,9 @@ class PolicyTable extends React.Component {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "Option",
|
title: i18next.t("general:Action"),
|
||||||
key: "option",
|
dataIndex: "",
|
||||||
|
key: "op",
|
||||||
width: "100px",
|
width: "100px",
|
||||||
render: (text, record, index) => {
|
render: (text, record, index) => {
|
||||||
const editable = this.isEditing(index);
|
const editable = this.isEditing(index);
|
||||||
@ -304,7 +305,6 @@ class PolicyTable extends React.Component {
|
|||||||
onChange: (page) => this.setState({
|
onChange: (page) => this.setState({
|
||||||
page: page,
|
page: page,
|
||||||
}),
|
}),
|
||||||
disabled: this.state.editingIndex !== "" || Setting.builtInObject({owner: this.props.owner, name: this.props.name}),
|
|
||||||
current: this.state.page,
|
current: this.state.page,
|
||||||
}}
|
}}
|
||||||
columns={columns} dataSource={table} rowKey="key" size="middle" bordered
|
columns={columns} dataSource={table} rowKey="key" size="middle" bordered
|
||||||
|
Reference in New Issue
Block a user