Changeset f25d07e for phonelux-backend/src/main/java/finki/it/phoneluxbackend/services/UserService.java
- Timestamp:
- 09/07/22 00:51:50 (2 years ago)
- Branches:
- master
- Children:
- 527b93f
- Parents:
- dbd4834
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
phonelux-backend/src/main/java/finki/it/phoneluxbackend/services/UserService.java
rdbd4834 rf25d07e 1 1 package finki.it.phoneluxbackend.services; 2 2 3 3 4 import finki.it.phoneluxbackend.entities.User; … … 5 6 import finki.it.phoneluxbackend.entities.ConfirmationToken; 6 7 import lombok.AllArgsConstructor; 8 9 import org.springframework.http.ResponseEntity; 7 10 import org.springframework.security.core.userdetails.UserDetails; 8 11 import org.springframework.security.core.userdetails.UserDetailsService; … … 12 15 13 16 import java.time.LocalDateTime; 17 14 18 import java.util.UUID; 15 19 … … 28 32 } 29 33 30 public StringsignUpUser(User user)34 public ResponseEntity<Object> signUpUser(User user) 31 35 { 32 boolean userExists = 36 boolean userExists = userRepository.findByEmail(user.getEmail()).isPresent(); 33 37 34 if (userExists && user.getEnabled()){ 35 throw new IllegalStateException("Email "+user.getEmail()+" already taken!"); 38 39 if (userExists){ 40 User userToRegister = userRepository.findByEmail(user.getEmail()).get(); 41 if(userToRegister.getEnabled()) { 42 return ResponseEntity.badRequest().body("Error: Email "+user.getEmail()+" already taken!"); 43 } 44 else { 45 return ResponseEntity.badRequest().body("Email "+user.getEmail()+" not activated!" ); 46 } 36 47 } 37 48 … … 49 60 confirmationTokenService.saveConfirmationToken(confirmationToken); 50 61 51 return token;62 return ResponseEntity.ok().body("token:"+token); 52 63 } 53 64
Note:
See TracChangeset
for help on using the changeset viewer.