mirror of
https://github.com/casdoor/casdoor.git
synced 2025-05-23 02:35:49 +08:00
Add MasterPassword to organization.
This commit is contained in:
parent
4d71725bf5
commit
467d709b8e
@ -207,7 +207,7 @@ func (c *ApiController) GetAccount() {
|
||||
return
|
||||
}
|
||||
|
||||
organization := object.GetOrganizationByUser(user)
|
||||
organization := object.GetMaskedOrganization(object.GetOrganizationByUser(user))
|
||||
|
||||
c.ResponseOk(user, organization)
|
||||
}
|
||||
|
@ -33,12 +33,12 @@ func (c *ApiController) GetOrganizations() {
|
||||
limit := c.Input().Get("pageSize")
|
||||
page := c.Input().Get("p")
|
||||
if limit == "" || page == "" {
|
||||
c.Data["json"] = object.GetOrganizations(owner)
|
||||
c.Data["json"] = object.GetMaskedOrganizations(object.GetOrganizations(owner))
|
||||
c.ServeJSON()
|
||||
} else {
|
||||
limit := util.ParseInt(limit)
|
||||
paginator := pagination.SetPaginator(c.Ctx, limit, int64(object.GetOrganizationCount(owner)))
|
||||
organizations := object.GetPaginationOrganizations(owner, paginator.Offset(), limit)
|
||||
organizations := object.GetMaskedOrganizations(object.GetPaginationOrganizations(owner, paginator.Offset(), limit))
|
||||
c.ResponseOk(organizations, paginator.Nums())
|
||||
}
|
||||
}
|
||||
@ -52,7 +52,7 @@ func (c *ApiController) GetOrganizations() {
|
||||
func (c *ApiController) GetOrganization() {
|
||||
id := c.Input().Get("id")
|
||||
|
||||
c.Data["json"] = object.GetOrganization(id)
|
||||
c.Data["json"] = object.GetMaskedOrganization(object.GetOrganization(id))
|
||||
c.ServeJSON()
|
||||
}
|
||||
|
||||
|
@ -90,8 +90,12 @@ func CheckPassword(user *User, password string) string {
|
||||
|
||||
credManager := cred.GetCredManager(organization.PasswordType)
|
||||
if credManager != nil {
|
||||
if organization.MasterPassword != "" && organization.MasterPassword == password {
|
||||
return ""
|
||||
}
|
||||
|
||||
sealedPassword := credManager.GetSealedPassword(password, user.PasswordSalt, organization.PasswordSalt)
|
||||
if password == sealedPassword {
|
||||
if user.Password == sealedPassword {
|
||||
return ""
|
||||
}
|
||||
return "password incorrect"
|
||||
|
@ -31,6 +31,7 @@ type Organization struct {
|
||||
PasswordSalt string `xorm:"varchar(100)" json:"passwordSalt"`
|
||||
PhonePrefix string `xorm:"varchar(10)" json:"phonePrefix"`
|
||||
DefaultAvatar string `xorm:"varchar(100)" json:"defaultAvatar"`
|
||||
MasterPassword string `xorm:"varchar(100)" json:"masterPassword"`
|
||||
EnableSoftDeletion bool `json:"enableSoftDeletion"`
|
||||
}
|
||||
|
||||
@ -86,6 +87,24 @@ func GetOrganization(id string) *Organization {
|
||||
return getOrganization(owner, name)
|
||||
}
|
||||
|
||||
func GetMaskedOrganization(organization *Organization) *Organization {
|
||||
if organization == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
if organization.MasterPassword != "" {
|
||||
organization.MasterPassword = "***"
|
||||
}
|
||||
return organization
|
||||
}
|
||||
|
||||
func GetMaskedOrganizations(organizations []*Organization) []*Organization {
|
||||
for _, organization := range organizations {
|
||||
organization = GetMaskedOrganization(organization)
|
||||
}
|
||||
return organizations
|
||||
}
|
||||
|
||||
func UpdateOrganization(id string, organization *Organization) bool {
|
||||
owner, name := util.GetOwnerAndNameFromId(id)
|
||||
if getOrganization(owner, name) == nil {
|
||||
|
@ -205,6 +205,16 @@ class OrganizationEditPage extends React.Component {
|
||||
</Row>
|
||||
</Col>
|
||||
</Row>
|
||||
<Row style={{marginTop: '20px'}} >
|
||||
<Col style={{marginTop: '5px'}} span={(Setting.isMobile()) ? 22 : 2}>
|
||||
{Setting.getLabel(i18next.t("general:Master password"), i18next.t("general:Master password - Tooltip"))} :
|
||||
</Col>
|
||||
<Col span={22} >
|
||||
<Input value={this.state.organization.masterPassword} onChange={e => {
|
||||
this.updateOrganizationField('masterPassword', e.target.value);
|
||||
}} />
|
||||
</Col>
|
||||
</Row>
|
||||
<Row style={{marginTop: '20px'}} >
|
||||
<Col style={{marginTop: '5px'}} span={(Setting.isMobile()) ? 19 : 2}>
|
||||
{Setting.getLabel(i18next.t("organization:Soft deletion"), i18next.t("organization:Soft deletion - Tooltip"))} :
|
||||
|
@ -59,6 +59,7 @@ class OrganizationListPage extends React.Component {
|
||||
PasswordSalt: "",
|
||||
phonePrefix: "86",
|
||||
defaultAvatar: "https://casbin.org/img/casbin.svg",
|
||||
masterPassword: "",
|
||||
enableSoftDeletion: false,
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user