mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-03 12:30:19 +08:00
Add User.isGlobalAdmin
This commit is contained in:
@ -44,6 +44,7 @@ func initBuiltInUser() {
|
|||||||
Affiliation: "Example Inc.",
|
Affiliation: "Example Inc.",
|
||||||
Tag: "staff",
|
Tag: "staff",
|
||||||
IsAdmin: true,
|
IsAdmin: true,
|
||||||
|
IsGlobalAdmin: true,
|
||||||
Github: "",
|
Github: "",
|
||||||
}
|
}
|
||||||
AddUser(user)
|
AddUser(user)
|
||||||
|
@ -34,6 +34,7 @@ type User struct {
|
|||||||
Affiliation string `xorm:"varchar(100)" json:"affiliation"`
|
Affiliation string `xorm:"varchar(100)" json:"affiliation"`
|
||||||
Tag string `xorm:"varchar(100)" json:"tag"`
|
Tag string `xorm:"varchar(100)" json:"tag"`
|
||||||
IsAdmin bool `json:"isAdmin"`
|
IsAdmin bool `json:"isAdmin"`
|
||||||
|
IsGlobalAdmin bool `json:"isGlobalAdmin"`
|
||||||
|
|
||||||
Github string `xorm:"varchar(100)" json:"github"`
|
Github string `xorm:"varchar(100)" json:"github"`
|
||||||
}
|
}
|
||||||
|
@ -194,6 +194,8 @@ class App extends Component {
|
|||||||
</Link>
|
</Link>
|
||||||
</Menu.Item>
|
</Menu.Item>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (Setting.isAdminUser(this.state.account)) {
|
||||||
res.push(
|
res.push(
|
||||||
<Menu.Item key="1">
|
<Menu.Item key="1">
|
||||||
<Link to="/organizations">
|
<Link to="/organizations">
|
||||||
@ -222,6 +224,7 @@ class App extends Component {
|
|||||||
</Link>
|
</Link>
|
||||||
</Menu.Item>
|
</Menu.Item>
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@ export function showMessage(type, text) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function isAdminUser(account) {
|
export function isAdminUser(account) {
|
||||||
return account.owner === "built-in";
|
return account.owner === "built-in" || account.isGlobalAdmin === true;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function deepCopy(obj) {
|
export function deepCopy(obj) {
|
||||||
|
@ -216,6 +216,9 @@ class UserEditPage extends React.Component {
|
|||||||
<Input value={this.state.user.github} disabled={true} />
|
<Input value={this.state.user.github} disabled={true} />
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
|
{
|
||||||
|
!Setting.isAdminUser(this.props.account) ? null : (
|
||||||
|
<React.Fragment>
|
||||||
<Row style={{marginTop: '20px'}} >
|
<Row style={{marginTop: '20px'}} >
|
||||||
<Col style={{marginTop: '5px'}} span={2}>
|
<Col style={{marginTop: '5px'}} span={2}>
|
||||||
Is Admin:
|
Is Admin:
|
||||||
@ -226,6 +229,19 @@ class UserEditPage extends React.Component {
|
|||||||
}} />
|
}} />
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
|
<Row style={{marginTop: '20px'}} >
|
||||||
|
<Col style={{marginTop: '5px'}} span={2}>
|
||||||
|
Is Global Admin:
|
||||||
|
</Col>
|
||||||
|
<Col span={1} >
|
||||||
|
<Switch checked={this.state.user.isGlobalAdmin} onChange={checked => {
|
||||||
|
this.updateUserField('isGlobalAdmin', checked);
|
||||||
|
}} />
|
||||||
|
</Col>
|
||||||
|
</Row>
|
||||||
|
</React.Fragment>
|
||||||
|
)
|
||||||
|
}
|
||||||
</Card>
|
</Card>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -208,6 +208,18 @@ class UserListPage extends React.Component {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
title: 'Is Global Admin',
|
||||||
|
dataIndex: 'isGlobalAdmin',
|
||||||
|
key: 'isGlobalAdmin',
|
||||||
|
width: '120px',
|
||||||
|
sorter: (a, b) => a.isGlobalAdmin.localeCompare(b.isGlobalAdmin),
|
||||||
|
render: (text, record, index) => {
|
||||||
|
return (
|
||||||
|
<Switch disabled checkedChildren="ON" unCheckedChildren="OFF" checked={text} />
|
||||||
|
)
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
title: 'Action',
|
title: 'Action',
|
||||||
dataIndex: '',
|
dataIndex: '',
|
||||||
|
Reference in New Issue
Block a user