Fix getCertByApplication()

This commit is contained in:
Yang Luo 2023-05-18 16:32:43 +08:00
parent 9f084a0799
commit 04eaad1c80
2 changed files with 30 additions and 2 deletions

View File

@ -134,6 +134,24 @@ func getCert(owner string, name string) *Cert {
}
}
func getCertByName(name string) *Cert {
if name == "" {
return nil
}
cert := Cert{Name: name}
existed, err := adapter.Engine.Get(&cert)
if err != nil {
panic(err)
}
if existed {
return &cert
} else {
return nil
}
}
func GetCert(id string) *Cert {
owner, name := util.GetOwnerAndNameFromId(id)
return getCert(owner, name)
@ -189,7 +207,7 @@ func (p *Cert) GetId() string {
func getCertByApplication(application *Application) *Cert {
if application.Cert != "" {
return getCert("admin", application.Cert)
return getCertByName(application.Cert)
} else {
return GetDefaultCert()
}

View File

@ -23,10 +23,20 @@ import BaseListPage from "./BaseListPage";
import PopconfirmModal from "./common/modal/PopconfirmModal";
class CertListPage extends BaseListPage {
constructor(props) {
super(props);
}
componentDidMount() {
this.setState({
owner: Setting.isAdminUser(this.props.account) ? "admin" : this.props.account.owner,
});
}
newCert() {
const randomName = Setting.getRandomName();
return {
owner: this.props.account.owner, // this.props.account.certname,
owner: this.state.owner,
name: `cert_${randomName}`,
createdTime: moment().format(),
displayName: `New Cert - ${randomName}`,