mirror of
https://github.com/ZwareBear/awx.git
synced 2026-04-14 03:51:49 -05:00
Raise a validation error if a credential is set while the service is not
This commit is contained in:
@@ -2836,11 +2836,13 @@ class JobTemplateMixin(object):
|
||||
'webhook_credential': _("Must be a Personal Access Token."),
|
||||
})
|
||||
|
||||
if webhook_service and webhook_credential:
|
||||
if webhook_credential.kind != '{}_token'.format(webhook_service):
|
||||
raise serializers.ValidationError({
|
||||
'webhook_credential': _("Must match the selected webhook service."),
|
||||
})
|
||||
if webhook_credential:
|
||||
msg = {'webhook_credential': _("Must match the selected webhook service.")}
|
||||
if webhook_service:
|
||||
if webhook_credential.kind != '{}_token'.format(webhook_service):
|
||||
raise serializers.ValidationError(msg)
|
||||
else:
|
||||
raise serializers.ValidationError(msg)
|
||||
|
||||
return super().validate(attrs)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user