diff options
author | Vitaly Takmazov | 2019-04-29 16:25:38 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2019-04-29 16:25:38 +0300 |
commit | f148f16ac82815f65f0b4ff44e1b2184ec0da0b0 (patch) | |
tree | 2c0b90be2036e6513e17a8b8f87c9d89cbeefb66 /src/main/java/com/juick/server/api | |
parent | 465e5571f8af340a3611290eba01c2b1d9fd22cd (diff) |
Refactoring
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); } |