aboutsummaryrefslogtreecommitdiff
path: root/juick-www/src/main/java/com/juick/www/controllers/SignUp.java
diff options
context:
space:
mode:
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.java35
1 files changed, 18 insertions, 17 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 02a8006b..11f02169 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
@@ -16,6 +16,7 @@
*/
package com.juick.www.controllers;
+import com.juick.User;
import com.juick.server.util.HttpBadRequestException;
import com.juick.server.util.HttpForbiddenException;
import com.juick.server.util.UserUtils;
@@ -95,7 +96,7 @@ public class SignUp {
@RequestParam(required = false) String username,
@RequestParam(required = false) String password) {
com.juick.User visitor = UserUtils.getCurrentUser();
- int uid = 0;
+ User signedUser = visitor;
if (hash.length() > 36 || !type.matches("^[a-zA-Z0-9\\-]+$") || !hash.matches("^[a-zA-Z0-9\\-]+$")) {
throw new HttpBadRequestException();
@@ -107,20 +108,20 @@ public class SignUp {
if (username.length() > 32) {
throw new HttpBadRequestException();
}
- uid = userService.checkPassword(username, password);
+ signedUser = userService.checkPassword(username, password);
} else {
- uid = visitor.getUid();
+ signedUser = visitor;
}
- if (uid <= 0) {
+ if (signedUser.isAnonymous()) {
throw new HttpForbiddenException();
}
- if (!(type.charAt(0) == 'f' && crosspostService.setFacebookUser(hash, uid))
- && !(type.charAt(0) == 'v' && crosspostService.setVKUser(hash, uid))
- && !(type.charAt(0) == 'd' && crosspostService.setTelegramUser(hash, uid))
- && !(type.charAt(0) == 'x' && crosspostService.setJIDUser(hash, uid))
- && !(type.charAt(0) == 'm' && messengerService.linkMessengerUser(hash, uid))) {
+ if (!(type.charAt(0) == 'f' && crosspostService.setFacebookUser(hash, signedUser))
+ && !(type.charAt(0) == 'v' && crosspostService.setVKUser(hash, signedUser))
+ && !(type.charAt(0) == 'd' && crosspostService.setTelegramUser(hash, signedUser))
+ && !(type.charAt(0) == 'x' && crosspostService.setJIDUser(hash, signedUser))
+ && !(type.charAt(0) == 'm' && messengerService.linkMessengerUser(hash, signedUser.getUid()))) {
throw new HttpBadRequestException();
}
@@ -131,22 +132,22 @@ public class SignUp {
// CHECK USERNAME
- uid = userService.createUser(username, password);
- if (uid <= 0) {
+ signedUser = userService.createUser(username, password);
+ if (signedUser.isAnonymous()) {
throw new HttpBadRequestException();
}
- if (!(type.charAt(0) == 'f' && crosspostService.setFacebookUser(hash, uid))
- && !(type.charAt(0) == 'v' && crosspostService.setVKUser(hash, uid))
- && !(type.charAt(0) == 'd' && crosspostService.setTelegramUser(hash, uid))
- && !(type.charAt(0) == 'x' && crosspostService.setJIDUser(hash, uid))
- && !(type.charAt(0) == 'm' && messengerService.linkMessengerUser(hash, uid))) {
+ if (!(type.charAt(0) == 'f' && crosspostService.setFacebookUser(hash, signedUser))
+ && !(type.charAt(0) == 'v' && crosspostService.setVKUser(hash, signedUser))
+ && !(type.charAt(0) == 'd' && crosspostService.setTelegramUser(hash, signedUser))
+ && !(type.charAt(0) == 'x' && crosspostService.setJIDUser(hash, signedUser))
+ && !(type.charAt(0) == 'm' && messengerService.linkMessengerUser(hash, signedUser.getUid()))) {
throw new HttpBadRequestException();
}
}
if (visitor.isAnonymous()) {
- hash = userService.getHashByUID(uid);
+ hash = userService.getHashForUser(signedUser);
Cookie c = new Cookie("hash", hash);
c.setMaxAge(365 * 24 * 60 * 60);
response.addCookie(c);