Skip to content

Commit

Permalink
Fix normal user my-account page blank bug
Browse files Browse the repository at this point in the history
  • Loading branch information
hsluoyz committed Mar 5, 2024
1 parent 92b6fda commit fbdd5a9
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
23 changes: 18 additions & 5 deletions object/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -469,14 +469,24 @@ func GetMaskedApplication(application *Application, userId string) *Application
application.FailedSigninFrozenTime = DefaultFailedSigninFrozenTime
}

isOrgUser := false
if userId != "" {
if isUserIdGlobalAdmin(userId) {
return application
}

user, _ := GetUser(userId)
if user != nil && user.IsApplicationAdmin(application) {
return application
user, err := GetUser(userId)
if err != nil {
panic(err)
}
if user != nil {
if user.IsApplicationAdmin(application) {
return application
}

if user.Owner == application.Organization {
isOrgUser = true
}
}
}

Expand Down Expand Up @@ -519,8 +529,11 @@ func GetMaskedApplication(application *Application, userId string) *Application
application.OrganizationObj.InitScore = -1
application.OrganizationObj.EnableSoftDeletion = false
application.OrganizationObj.IsProfilePublic = false
application.OrganizationObj.MfaItems = nil
application.OrganizationObj.AccountItems = nil

if !isOrgUser {
application.OrganizationObj.MfaItems = nil
application.OrganizationObj.AccountItems = nil
}
}

return application
Expand Down
6 changes: 4 additions & 2 deletions web/src/UserEditPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ class UserEditPage extends React.Component {

UNSAFE_componentWillMount() {
this.getUser();
this.getOrganizations();
if (Setting.isLocalAdminUser(this.props.account)) {
this.getOrganizations();
}
this.getApplicationsByOrganization(this.state.organizationName);
this.getUserApplication();
this.setReturnUrl();
Expand Down Expand Up @@ -1001,7 +1003,7 @@ class UserEditPage extends React.Component {
<div style={{verticalAlign: "middle", marginBottom: 10}}>{`(${i18next.t("general:empty")})`}</div>
</Col>
}
<CropperDivModal disabled={disabled} tag={tag} setTitle={set} buttonText={`${title}...`} title={title} user={this.state.user} organization={this.state.organizations.find(organization => organization.name === this.state.organizationName)} />
<CropperDivModal disabled={disabled} tag={tag} setTitle={set} buttonText={`${title}...`} title={title} user={this.state.user} organization={this.getUserOrganization()} />
</Col>
);
}
Expand Down

0 comments on commit fbdd5a9

Please sign in to comment.