diff options
Diffstat (limited to 'src/main/java/com/juick/server/api')
-rw-r--r-- | src/main/java/com/juick/server/api/ApiSocialLogin.java | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/src/main/java/com/juick/server/api/ApiSocialLogin.java b/src/main/java/com/juick/server/api/ApiSocialLogin.java index fe5f2069..2d0a5c7e 100644 --- a/src/main/java/com/juick/server/api/ApiSocialLogin.java +++ b/src/main/java/com/juick/server/api/ApiSocialLogin.java @@ -302,13 +302,10 @@ public class ApiSocialLogin { String verifiedEmail = emailService.getEmailByAuthCode(verificationCode); if (StringUtils.isNotEmpty(verifiedEmail)) { - int uid = userService.createUser(username, password); - if (uid <= 0) { - throw new HttpBadRequestException(); - } - emailService.addEmail(uid, verifiedEmail); + com.juick.User newUser = userService.createUser(username, password).orElseThrow(HttpBadRequestException::new); + emailService.addEmail(newUser.getUid(), verifiedEmail); emailService.deleteAuthCode(verificationCode); - return ResponseEntity.ok(userService.getUserByUID(uid).orElseThrow(IllegalStateException::new)); + return ResponseEntity.ok(newUser); } else { return ResponseEntity.status(HttpStatus.FORBIDDEN).body(null); } |