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:
@ -31,20 +31,21 @@ func initBuiltInUser() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
user = &User{
|
user = &User{
|
||||||
Owner: "built-in",
|
Owner: "built-in",
|
||||||
Name: "admin",
|
Name: "admin",
|
||||||
CreatedTime: util.GetCurrentTime(),
|
CreatedTime: util.GetCurrentTime(),
|
||||||
Id: util.GenerateId(),
|
Id: util.GenerateId(),
|
||||||
Password: "123",
|
Password: "123",
|
||||||
PasswordType: "plain",
|
PasswordType: "plain",
|
||||||
DisplayName: "Admin",
|
DisplayName: "Admin",
|
||||||
Avatar: "https://casbin.org/img/casbin.svg",
|
Avatar: "https://casbin.org/img/casbin.svg",
|
||||||
Email: "admin@example.com",
|
Email: "admin@example.com",
|
||||||
Phone: "1-12345678",
|
Phone: "1-12345678",
|
||||||
Affiliation: "Example Inc.",
|
Affiliation: "Example Inc.",
|
||||||
Tag: "staff",
|
Tag: "staff",
|
||||||
IsAdmin: true,
|
IsAdmin: true,
|
||||||
Github: "",
|
IsGlobalAdmin: true,
|
||||||
|
Github: "",
|
||||||
}
|
}
|
||||||
AddUser(user)
|
AddUser(user)
|
||||||
}
|
}
|
||||||
|
@ -24,16 +24,17 @@ type User struct {
|
|||||||
Name string `xorm:"varchar(100) notnull pk" json:"name"`
|
Name string `xorm:"varchar(100) notnull pk" json:"name"`
|
||||||
CreatedTime string `xorm:"varchar(100)" json:"createdTime"`
|
CreatedTime string `xorm:"varchar(100)" json:"createdTime"`
|
||||||
|
|
||||||
Id string `xorm:"varchar(100)" json:"id"`
|
Id string `xorm:"varchar(100)" json:"id"`
|
||||||
Password string `xorm:"varchar(100)" json:"password"`
|
Password string `xorm:"varchar(100)" json:"password"`
|
||||||
PasswordType string `xorm:"varchar(100)" json:"passwordType"`
|
PasswordType string `xorm:"varchar(100)" json:"passwordType"`
|
||||||
DisplayName string `xorm:"varchar(100)" json:"displayName"`
|
DisplayName string `xorm:"varchar(100)" json:"displayName"`
|
||||||
Avatar string `xorm:"varchar(100)" json:"avatar"`
|
Avatar string `xorm:"varchar(100)" json:"avatar"`
|
||||||
Email string `xorm:"varchar(100)" json:"email"`
|
Email string `xorm:"varchar(100)" json:"email"`
|
||||||
Phone string `xorm:"varchar(100)" json:"phone"`
|
Phone string `xorm:"varchar(100)" json:"phone"`
|
||||||
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,34 +194,37 @@ class App extends Component {
|
|||||||
</Link>
|
</Link>
|
||||||
</Menu.Item>
|
</Menu.Item>
|
||||||
);
|
);
|
||||||
res.push(
|
|
||||||
<Menu.Item key="1">
|
if (Setting.isAdminUser(this.state.account)) {
|
||||||
<Link to="/organizations">
|
res.push(
|
||||||
Organizations
|
<Menu.Item key="1">
|
||||||
</Link>
|
<Link to="/organizations">
|
||||||
</Menu.Item>
|
Organizations
|
||||||
);
|
</Link>
|
||||||
res.push(
|
</Menu.Item>
|
||||||
<Menu.Item key="2">
|
);
|
||||||
<Link to="/users">
|
res.push(
|
||||||
Users
|
<Menu.Item key="2">
|
||||||
</Link>
|
<Link to="/users">
|
||||||
</Menu.Item>
|
Users
|
||||||
);
|
</Link>
|
||||||
res.push(
|
</Menu.Item>
|
||||||
<Menu.Item key="3">
|
);
|
||||||
<Link to="/providers">
|
res.push(
|
||||||
Providers
|
<Menu.Item key="3">
|
||||||
</Link>
|
<Link to="/providers">
|
||||||
</Menu.Item>
|
Providers
|
||||||
);
|
</Link>
|
||||||
res.push(
|
</Menu.Item>
|
||||||
<Menu.Item key="4">
|
);
|
||||||
<Link to="/applications">
|
res.push(
|
||||||
Applications
|
<Menu.Item key="4">
|
||||||
</Link>
|
<Link to="/applications">
|
||||||
</Menu.Item>
|
Applications
|
||||||
);
|
</Link>
|
||||||
|
</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,16 +216,32 @@ 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>
|
||||||
<Row style={{marginTop: '20px'}} >
|
{
|
||||||
<Col style={{marginTop: '5px'}} span={2}>
|
!Setting.isAdminUser(this.props.account) ? null : (
|
||||||
Is Admin:
|
<React.Fragment>
|
||||||
</Col>
|
<Row style={{marginTop: '20px'}} >
|
||||||
<Col span={1} >
|
<Col style={{marginTop: '5px'}} span={2}>
|
||||||
<Switch checked={this.state.user.isAdmin} onChange={checked => {
|
Is Admin:
|
||||||
this.updateUserField('isAdmin', checked);
|
</Col>
|
||||||
}} />
|
<Col span={1} >
|
||||||
</Col>
|
<Switch checked={this.state.user.isAdmin} onChange={checked => {
|
||||||
</Row>
|
this.updateUserField('isAdmin', checked);
|
||||||
|
}} />
|
||||||
|
</Col>
|
||||||
|
</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