poeti8 7 лет назад
Родитель
Сommit
98e29c2548
2 измененных файлов с 15 добавлено и 7 удалено
  1. 11 7
      client/pages/report.js
  2. 4 0
      server/controllers/urlController.js

+ 11 - 7
client/pages/report.js

@@ -23,12 +23,12 @@ const Form = styled.form`
 const Message = styled.p`
   position: absolute;
   left: 0;
-  bottom: -48px;
+  bottom: -54px;
   font-size: 14px;
   color: ${props => (props.type === 'error' ? 'red' : 'green')};
 
   @media only screen and (max-width: 448px) {
-    bottom: -40px;
+    bottom: -44px;
     font-size: 12px;
   }
 `;
@@ -64,6 +64,7 @@ class ReportPage extends Component {
           type: 'success',
           text: "Thanks for the report, we'll take actions shortly.",
         },
+        url: '',
       });
     } catch (error) {
       this.setState({
@@ -72,6 +73,7 @@ class ReportPage extends Component {
           type: 'error',
           text: error.response.data.error,
         },
+        url: '',
       });
     }
 
@@ -82,7 +84,7 @@ class ReportPage extends Component {
           text: '',
         },
       });
-    }, 2000);
+    }, 5000);
   }
 
   render() {
@@ -93,15 +95,17 @@ class ReportPage extends Component {
         <Wrapper>
           <h3>Report abuse</h3>
           <p>
-            Report abuses, malware and phishing links to the below email address. We will take
-            actions shortly.
+            Report abuses, malware and phishing links to the below email address or use the form. We
+            will take actions shortly.
           </p>
           <p>{REPORT_EMAIL}</p>
-          <p>Or use the form below.</p>
+          <p>
+            <b>URL containting malware/scam:</b>
+          </p>
           <Form onSubmit={this.onSubmit}>
             <TextInput
               type="text"
-              placeholder="URL"
+              placeholder="kutt.it/example"
               value={url}
               onChange={this.onChange}
               height={44}

+ 4 - 0
server/controllers/urlController.js

@@ -241,6 +241,10 @@ exports.getStats = async ({ query: { id, domain }, user }, res) => {
 
 exports.reportUrl = async ({ body: { url } }, res) => {
   if (!url) return res.status(400).json({ error: 'No URL has been provided.' });
+
+  const isValidUrl = urlRegex({ exact: true, strict: false }).test(url);
+  if (!isValidUrl) return res.status(400).json({ error: 'URL is not valid.' });
+
   const mail = await transporter.sendMail({
     from: config.MAIL_USER,
     to: config.REPORT_MAIL,