diff --git a/server/plugin.go b/server/plugin.go index 3254ab824..e3214b99b 100644 --- a/server/plugin.go +++ b/server/plugin.go @@ -420,29 +420,31 @@ func (p *Plugin) restart() { func (p *Plugin) generatePluginSecrets() error { needSaveConfig := false - if p.configuration.WebhookSecret == "" { + cfg := p.getConfiguration().Clone() + if cfg.WebhookSecret == "" { secret, err := generateSecret() if err != nil { return err } - p.configuration.WebhookSecret = secret + cfg.WebhookSecret = secret needSaveConfig = true } - if p.configuration.EncryptionKey == "" { + if cfg.EncryptionKey == "" { secret, err := generateSecret() if err != nil { return err } - p.configuration.EncryptionKey = secret + cfg.EncryptionKey = secret needSaveConfig = true } if needSaveConfig { - configMap, err := p.configuration.ToMap() + configMap, err := cfg.ToMap() if err != nil { return err } + p.setConfiguration(cfg) if appErr := p.API.SavePluginConfig(configMap); appErr != nil { return appErr }