|
@@ -9,16 +9,18 @@ |
9 |
9 |
|
|
10 |
10 |
|
import org.omg.CORBA.UserException; |
11 |
11 |
|
import org.springframework.beans.factory.annotation.Autowired; |
|
12 |
+ |
import org.springframework.http.HttpStatus; |
12 |
13 |
|
import org.springframework.security.core.userdetails.UserDetails; |
13 |
14 |
|
import org.springframework.security.core.userdetails.UserDetailsService; |
14 |
15 |
|
import org.springframework.security.core.userdetails.UsernameNotFoundException; |
15 |
16 |
|
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; |
16 |
17 |
|
import org.springframework.stereotype.Service; |
17 |
18 |
|
import org.springframework.validation.BindingResult; |
|
19 |
+ |
import org.springframework.web.server.ResponseStatusException; |
18 |
20 |
|
|
|
21 |
+ |
import com.bestray.model.entity.SpecialityMaster; |
19 |
22 |
|
import com.bestray.model.security.Authority; |
20 |
|
- |
import com.bestray.model.security.DepartmentMaster; |
21 |
|
- |
import com.bestray.model.security.SpecialityMaster; |
|
23 |
+ |
import com.bestray.model.entity.DepartmentMaster; |
22 |
24 |
|
import com.bestray.model.security.User; |
23 |
25 |
|
import com.bestray.security.JwtAuthenticationRequest; |
24 |
26 |
|
import com.bestray.security.JwtUser; |
|
@@ -67,7 +69,7 @@ |
67 |
69 |
|
String username=authenticationRequest.getUsername(); |
68 |
70 |
|
User userExists =userRepository.findByUsername(username); |
69 |
71 |
|
if (userExists != null) { |
70 |
|
- |
throw new RegExceptionHandler(); |
|
72 |
+ |
throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "user already avilable"); |
71 |
73 |
|
}else{ |
72 |
74 |
|
authenticationRequest.setPassword(bCryptPasswordEncoder.encode(authenticationRequest.getPassword())); |
73 |
75 |
|
authenticationRequest.setEnabled(true); |
|
@@ -98,7 +100,8 @@ |
98 |
100 |
|
userRepository.save(user_new); |
99 |
101 |
|
System.out.println("2@@@@@"); |
100 |
102 |
|
}else{ |
101 |
|
- |
throw new ExceptionHandler_update(); } |
|
103 |
+ |
throw new ResponseStatusException(HttpStatus.NOT_FOUND, "given id is not avilable"); |
|
104 |
+ |
} |
102 |
105 |
|
} |
103 |
106 |
|
} |
104 |
107 |
|
|
|
@@ -112,7 +115,7 @@ |
112 |
115 |
|
user_new.setEnabled(false); |
113 |
116 |
|
userRepository.save(user_new); |
114 |
117 |
|
}else{ |
115 |
|
- |
throw new ExceptionHandler_delete(); |
|
118 |
+ |
throw new ResponseStatusException(HttpStatus.NOT_FOUND, "given id is not avilable"); |
116 |
119 |
|
|
117 |
120 |
|
} |
118 |
121 |
|
} |
|
@@ -138,7 +141,7 @@ |
138 |
141 |
|
Authority roleExists =authorityRepository.findByName(authority.getName()); |
139 |
142 |
|
//System.out.println("#1permission->"+roleExists); |
140 |
143 |
|
if (roleExists != null) { |
141 |
|
- |
throw new RoleExceptionHandler(); |
|
144 |
+ |
throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "role already avilable"); |
142 |
145 |
|
}else{ |
143 |
146 |
|
// System.out.println("1@@@@@ "+authenticationRequest.getEmail()+" "+authenticationRequest.getPassword()+" "+authenticationRequest.getFirstname()+" "+authenticationRequest.getLastname()+" "+authenticationRequest.getUsername()+" "+authenticationRequest.getId()+" "+authenticationRequest.getEnabled()+" "+authenticationRequest.getLastPasswordResetDate()); |
144 |
147 |
|
authorityRepository.save(authority); |