Fix bug that cannot access application's public certificate for non "admin" owner

This commit is contained in:
Yang Luo
2023-09-15 00:54:33 +08:00
parent a12ba7fb85
commit b633ecdcf2

View File

@ -90,14 +90,24 @@ func (c *ApiController) GetApplication() {
return
}
if c.Input().Get("withKey") != "" && application.Cert != "" {
if c.Input().Get("withKey") != "" && application != nil && application.Cert != "" {
cert, err := object.GetCert(util.GetId(application.Owner, application.Cert))
if err != nil {
c.ResponseError(err.Error())
return
}
application.CertPublicKey = cert.Certificate
if cert == nil {
cert, err = object.GetCert(util.GetId(application.Organization, application.Cert))
if err != nil {
c.ResponseError(err.Error())
return
}
}
if cert != nil {
application.CertPublicKey = cert.Certificate
}
}
c.ResponseOk(object.GetMaskedApplication(application, userId))