import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
@Autowired
private UserService userService;
+ private static final String HIDDEN_DEFAULT_PASSWORD = "*****";
+
/**
* RESTful service method to get ONAP Logged in User details.
*
*
* @return PortalRestResponse of EPUser
*/
- @RequestMapping(value = { "/portalApi/loggedinUser" }, method = RequestMethod.GET, produces = "application/json")
+ @GetMapping(value = { "/portalApi/loggedinUser" }, produces = "application/json")
public PortalRestResponse<ProfileDetail> getLoggedinUser(HttpServletRequest request) {
PortalRestResponse<ProfileDetail> portalRestResponse = null;
try {
EPUser user = EPUserUtils.getUserSession(request);
ProfileDetail profileDetail = new ProfileDetail(user.getFirstName(), user.getLastName(),
- user.getMiddleInitial(), user.getEmail(), user.getLoginId(), CipherUtil.decryptPKC(user.getLoginPwd()));
+ user.getMiddleInitial(), user.getEmail(), user.getLoginId(), HIDDEN_DEFAULT_PASSWORD);
portalRestResponse = new PortalRestResponse<ProfileDetail>(PortalRestStatusEnum.OK, "success",
profileDetail);
EcompPortalUtils.logAndSerializeObject(logger, "/portalApi/loggedinUser", "result =", profileDetail);
* Body with user information
* @return PortalRestResponse of String
*/
- @RequestMapping(value = {
- "/portalApi/modifyLoggedinUser" }, method = RequestMethod.PUT, produces = "application/json")
+ @PutMapping(value = {
+ "/portalApi/modifyLoggedinUser" }, produces = "application/json")
public PortalRestResponse<String> modifyLoggedinUser(HttpServletRequest request,
@RequestBody ProfileDetail profileDetail) {
PortalRestResponse<String> portalRestResponse = null;
user.setEmail(profileDetail.getEmail());
user.setMiddleInitial(profileDetail.getMiddleName());
user.setLoginId(profileDetail.getLoginId());
- user.setLoginPwd(CipherUtil.encryptPKC(profileDetail.getLoginPassword()));
+ if (!HIDDEN_DEFAULT_PASSWORD.equals(profileDetail.getLoginPassword())){
+ user.setLoginPwd(CipherUtil.encryptPKC(profileDetail.getLoginPassword()));
+ }
userService.saveUser(user);
// Update user info in the session
request.getSession().setAttribute(SystemProperties.getProperty(SystemProperties.USER_ATTRIBUTE_NAME),