mirror of
https://github.com/fallenbagel/jellyseerr.git
synced 2026-01-01 04:08:45 -05:00
fix(ui): Add additional URL & email input validation (#843)
This commit is contained in:
@@ -14,13 +14,13 @@ const messages = defineMessages({
|
||||
saving: 'Saving…',
|
||||
agentenabled: 'Enable Agent',
|
||||
webhookUrl: 'Webhook URL',
|
||||
validationWebhookUrlRequired: 'You must provide a webhook URL',
|
||||
webhookUrlPlaceholder: 'Server Settings → Integrations → Webhooks',
|
||||
discordsettingssaved: 'Discord notification settings saved!',
|
||||
discordsettingsfailed: 'Discord notification settings failed to save.',
|
||||
testsent: 'Test notification sent!',
|
||||
test: 'Test',
|
||||
notificationtypes: 'Notification Types',
|
||||
validationWebhookUrl: 'You must provide a valid URL',
|
||||
});
|
||||
|
||||
const NotificationsDiscord: React.FC = () => {
|
||||
@@ -31,9 +31,9 @@ const NotificationsDiscord: React.FC = () => {
|
||||
);
|
||||
|
||||
const NotificationsDiscordSchema = Yup.object().shape({
|
||||
webhookUrl: Yup.string().required(
|
||||
intl.formatMessage(messages.validationWebhookUrlRequired)
|
||||
),
|
||||
webhookUrl: Yup.string()
|
||||
.required(intl.formatMessage(messages.validationWebhookUrl))
|
||||
.url(intl.formatMessage(messages.validationWebhookUrl)),
|
||||
});
|
||||
|
||||
if (!data && !error) {
|
||||
|
||||
@@ -12,7 +12,6 @@ import NotificationTypeSelector from '../../NotificationTypeSelector';
|
||||
const messages = defineMessages({
|
||||
save: 'Save Changes',
|
||||
saving: 'Saving…',
|
||||
validationFromRequired: 'You must provide a sender address',
|
||||
validationSmtpHostRequired: 'You must provide an SMTP host',
|
||||
validationSmtpPortRequired: 'You must provide an SMTP port',
|
||||
agentenabled: 'Enable Agent',
|
||||
@@ -31,6 +30,7 @@ const messages = defineMessages({
|
||||
'SSL should be disabled on standard TLS connections (port 587)',
|
||||
senderName: 'Sender Name',
|
||||
notificationtypes: 'Notification Types',
|
||||
validationEmail: 'You must provide a valid email address',
|
||||
});
|
||||
|
||||
const NotificationsEmail: React.FC = () => {
|
||||
@@ -41,9 +41,9 @@ const NotificationsEmail: React.FC = () => {
|
||||
);
|
||||
|
||||
const NotificationsEmailSchema = Yup.object().shape({
|
||||
emailFrom: Yup.string().required(
|
||||
intl.formatMessage(messages.validationFromRequired)
|
||||
),
|
||||
emailFrom: Yup.string()
|
||||
.required(intl.formatMessage(messages.validationEmail))
|
||||
.email(intl.formatMessage(messages.validationEmail)),
|
||||
smtpHost: Yup.string().required(
|
||||
intl.formatMessage(messages.validationSmtpHostRequired)
|
||||
),
|
||||
|
||||
@@ -15,7 +15,6 @@ const messages = defineMessages({
|
||||
saving: 'Saving…',
|
||||
agentenabled: 'Enable Agent',
|
||||
webhookUrl: 'Webhook URL',
|
||||
validationWebhookUrlRequired: 'You must provide a webhook URL',
|
||||
webhookUrlPlaceholder: 'Webhook URL',
|
||||
slacksettingssaved: 'Slack notification settings saved!',
|
||||
slacksettingsfailed: 'Slack notification settings failed to save.',
|
||||
@@ -25,6 +24,7 @@ const messages = defineMessages({
|
||||
settingupslackDescription:
|
||||
'To use Slack notifications, you will need to create an <WebhookLink>Incoming Webhook</WebhookLink> integration and use the provided webhook URL below.',
|
||||
notificationtypes: 'Notification Types',
|
||||
validationWebhookUrl: 'You must provide a valid URL',
|
||||
});
|
||||
|
||||
const NotificationsSlack: React.FC = () => {
|
||||
@@ -35,9 +35,9 @@ const NotificationsSlack: React.FC = () => {
|
||||
);
|
||||
|
||||
const NotificationsSlackSchema = Yup.object().shape({
|
||||
webhookUrl: Yup.string().required(
|
||||
intl.formatMessage(messages.validationWebhookUrlRequired)
|
||||
),
|
||||
webhookUrl: Yup.string()
|
||||
.required(intl.formatMessage(messages.validationWebhookUrl))
|
||||
.url(intl.formatMessage(messages.validationWebhookUrl)),
|
||||
});
|
||||
|
||||
if (!data && !error) {
|
||||
|
||||
@@ -37,7 +37,6 @@ const messages = defineMessages({
|
||||
agentenabled: 'Enable Agent',
|
||||
webhookUrl: 'Webhook URL',
|
||||
authheader: 'Authorization Header',
|
||||
validationWebhookUrlRequired: 'You must provide a webhook URL',
|
||||
validationJsonPayloadRequired: 'You must provide a JSON Payload',
|
||||
webhookUrlPlaceholder: 'Remote webhook URL',
|
||||
webhooksettingssaved: 'Webhook notification settings saved!',
|
||||
@@ -49,6 +48,7 @@ const messages = defineMessages({
|
||||
resetPayloadSuccess: 'JSON reset to default payload.',
|
||||
customJson: 'Custom JSON Payload',
|
||||
templatevariablehelp: 'Template Variable Help',
|
||||
validationWebhookUrl: 'You must provide a valid URL',
|
||||
});
|
||||
|
||||
const NotificationsWebhook: React.FC = () => {
|
||||
@@ -59,9 +59,13 @@ const NotificationsWebhook: React.FC = () => {
|
||||
);
|
||||
|
||||
const NotificationsWebhookSchema = Yup.object().shape({
|
||||
webhookUrl: Yup.string().required(
|
||||
intl.formatMessage(messages.validationWebhookUrlRequired)
|
||||
),
|
||||
webhookUrl: Yup.string()
|
||||
.required(intl.formatMessage(messages.validationWebhookUrl))
|
||||
.matches(
|
||||
// eslint-disable-next-line
|
||||
/^(https?:)?\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*)?([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/,
|
||||
intl.formatMessage(messages.validationWebhookUrl)
|
||||
),
|
||||
jsonPayload: Yup.string()
|
||||
.required(intl.formatMessage(messages.validationJsonPayloadRequired))
|
||||
.test('validate-json', 'Invalid JSON', (value) => {
|
||||
|
||||
Reference in New Issue
Block a user