aboutsummaryrefslogtreecommitdiff
path: root/juick-www/src/main/java/com/juick/www/controllers/SignUp.java
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2017-04-07 11:01:29 +0300
committerGravatar Vitaly Takmazov2017-04-07 11:01:29 +0300
commit47d7e0e533687b204e6c781f0dce57ca54e01348 (patch)
tree9fa81730de771be5695a544a24d63d0ae1992cfc /juick-www/src/main/java/com/juick/www/controllers/SignUp.java
parent9820abe11c0c037f50bb2f7ddbb0bd19646264dc (diff)
juick-www: refactoring, drop userref shit
Diffstat (limited to 'juick-www/src/main/java/com/juick/www/controllers/SignUp.java')
-rw-r--r--juick-www/src/main/java/com/juick/www/controllers/SignUp.java47
1 files changed, 14 insertions, 33 deletions
diff --git a/juick-www/src/main/java/com/juick/www/controllers/SignUp.java b/juick-www/src/main/java/com/juick/www/controllers/SignUp.java
index d07c3227..4746292b 100644
--- a/juick-www/src/main/java/com/juick/www/controllers/SignUp.java
+++ b/juick-www/src/main/java/com/juick/www/controllers/SignUp.java
@@ -23,16 +23,15 @@ import com.juick.service.CrosspostService;
import com.juick.service.MessagesService;
import com.juick.service.UserService;
import com.juick.util.UserUtils;
-import com.juick.www.Utils;
import com.juick.www.WebApp;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestParam;
import javax.inject.Inject;
import javax.servlet.http.Cookie;
-import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
@@ -53,13 +52,11 @@ public class SignUp {
@GetMapping("/signup")
- protected String doGet(HttpServletRequest request, HttpServletResponse response, ModelMap model) {
+ protected String doGet(@RequestParam String type, @RequestParam String hash, ModelMap model) {
com.juick.User visitor = UserUtils.getCurrentUser();
- String type = request.getParameter("type");
- String hash = request.getParameter("hash");
- if (type == null || type.isEmpty() || hash == null || hash.isEmpty() || hash.length() > 36
- || !type.matches("^[a-zA-Z0-9\\-]+$") || !hash.matches("^[a-zA-Z0-9\\-]+$")) {
+ if (hash.length() > 36 || !type.matches("^[a-zA-Z0-9\\-]+$")
+ || !hash.matches("^[a-zA-Z0-9\\-]+$")) {
throw new HttpBadRequestException();
}
@@ -92,23 +89,24 @@ public class SignUp {
}
@PostMapping("/signup")
- protected String doPost(HttpServletRequest request, HttpServletResponse response) {
+ protected String doPost(
+ HttpServletResponse response,
+ @RequestParam String type,
+ @RequestParam String hash,
+ @RequestParam String action,
+ @RequestParam String username,
+ @RequestParam String password) {
com.juick.User visitor = UserUtils.getCurrentUser();
int uid = 0;
- String type = request.getParameter("type");
- String hash = request.getParameter("hash");
- if (type == null || type.isEmpty() || hash == null || hash.isEmpty() || hash.length() > 36 || !type.matches("^[a-zA-Z0-9\\-]+$") || !hash.matches("^[a-zA-Z0-9\\-]+$")) {
+ if (hash.length() > 36 || !type.matches("^[a-zA-Z0-9\\-]+$") || !hash.matches("^[a-zA-Z0-9\\-]+$")) {
throw new HttpBadRequestException();
}
- String action = request.getParameter("action");
if (action.charAt(0) == 'l') {
if (visitor.getUid() == 0) {
- String username = request.getParameter("username");
- String password = request.getParameter("password");
- if (username == null || password == null || username.length() > 32 || password.isEmpty()) {
+ if (username.length() > 32) {
throw new HttpBadRequestException();
}
uid = userService.checkPassword(username, password);
@@ -128,9 +126,7 @@ public class SignUp {
}
} else { // Create new account
- String username = request.getParameter("username");
- String password = request.getParameter("password");
- if (username == null || password == null || username.length() < 2 || username.length() > 16 || !username.matches("^[a-zA-Z0-9\\-]+$") || password.length() < 6 || password.length() > 32) {
+ if (username.length() < 2 || username.length() > 16 || !username.matches("^[a-zA-Z0-9\\-]+$") || password.length() < 6 || password.length() > 32) {
throw new HttpBadRequestException();
}
@@ -147,21 +143,6 @@ public class SignUp {
&& !(type.charAt(0) == 'x' && crosspostService.setJIDUser(hash, uid))) {
throw new HttpBadRequestException();
}
-
- int ref = 0;
- String sRef = Utils.getCookie(request, "ref");
- if (sRef != null) {
- try {
- ref = Integer.parseInt(sRef);
- } catch (Exception e) {
- }
- }
-
- if (ref > 0) {
- crosspostService.setUserRef(uid, ref);
- }
-
- visitor = null;
}
if (visitor == null) {