mirror of
https://github.com/TeamPiped/Piped-Backend.git
synced 2024-12-13 22:00:29 +05:30
Handle invalid requests gracefully.
This commit is contained in:
parent
d6e998eef7
commit
a1ed146924
@ -84,6 +84,7 @@ import me.kavin.piped.utils.resp.AcceptedResponse;
|
||||
import me.kavin.piped.utils.resp.AlreadyRegisteredResponse;
|
||||
import me.kavin.piped.utils.resp.AuthenticationFailureResponse;
|
||||
import me.kavin.piped.utils.resp.IncorrectCredentialsResponse;
|
||||
import me.kavin.piped.utils.resp.InvalidRequestResponse;
|
||||
import me.kavin.piped.utils.resp.LoginResponse;
|
||||
import me.kavin.piped.utils.resp.SubscribeStatusResponse;
|
||||
|
||||
@ -263,6 +264,9 @@ public class ResponseHelper {
|
||||
public static final byte[] trendingResponse(String region)
|
||||
throws ParsingException, ExtractionException, IOException {
|
||||
|
||||
if (region == null)
|
||||
return Constants.mapper.writeValueAsBytes(new InvalidRequestResponse());
|
||||
|
||||
final List<StreamItem> relatedStreams = new ObjectArrayList<>();
|
||||
|
||||
KioskList kioskList = Constants.YOUTUBE_SERVICE.getKioskList();
|
||||
@ -515,6 +519,9 @@ public class ResponseHelper {
|
||||
public static final byte[] registerResponse(String user, String pass)
|
||||
throws IOException, NoSuchAlgorithmException, InvalidKeySpecException {
|
||||
|
||||
if (user == null || pass == null)
|
||||
return Constants.mapper.writeValueAsBytes(new InvalidRequestResponse());
|
||||
|
||||
user = user.toLowerCase();
|
||||
|
||||
Session s = DatabaseSessionFactory.createSession();
|
||||
@ -544,6 +551,9 @@ public class ResponseHelper {
|
||||
public static final byte[] loginResponse(String user, String pass)
|
||||
throws IOException, NoSuchAlgorithmException, InvalidKeySpecException {
|
||||
|
||||
if (user == null || pass == null)
|
||||
return Constants.mapper.writeValueAsBytes(new InvalidRequestResponse());
|
||||
|
||||
user = user.toLowerCase();
|
||||
|
||||
Session s = DatabaseSessionFactory.createSession();
|
||||
|
@ -0,0 +1,7 @@
|
||||
package me.kavin.piped.utils.resp;
|
||||
|
||||
public class InvalidRequestResponse {
|
||||
|
||||
public String message = "Invalid request sent.";
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user