forked from coracle/zooid
Validate presence of pubkey in config
This commit is contained in:
+5
-4
@@ -291,10 +291,11 @@ func (api *APIHandler) validatePatchedConfig(config *Config) error {
|
||||
if _, err := nostr.SecretKeyFromHex(config.Secret); err != nil {
|
||||
return fmt.Errorf("invalid secret key: %w", err)
|
||||
}
|
||||
if config.Info.Pubkey != "" {
|
||||
if _, err := nostr.PubKeyFromHex(config.Info.Pubkey); err != nil {
|
||||
return fmt.Errorf("invalid info.pubkey: %w", err)
|
||||
}
|
||||
if config.Info.Pubkey == "" {
|
||||
return fmt.Errorf("info.pubkey is required")
|
||||
}
|
||||
if _, err := nostr.PubKeyFromHex(config.Info.Pubkey); err != nil {
|
||||
return fmt.Errorf("invalid info.pubkey: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -77,6 +77,10 @@ func LoadConfig(filename string) (*Config, error) {
|
||||
return nil, fmt.Errorf("schema is required")
|
||||
}
|
||||
|
||||
if config.Info.Pubkey == "" {
|
||||
return nil, fmt.Errorf("info.pubkey is required")
|
||||
}
|
||||
|
||||
secret, err := nostr.SecretKeyFromHex(config.Secret)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
Reference in New Issue
Block a user