/** * 사용자 정보 수정 * * @return */ public static Result editUserInfo() { Form<User> userForm = new Form<>(User.class).bindFromRequest("name", "email"); String newEmail = userForm.data().get("email"); String newName = userForm.data().get("name"); User user = UserApp.currentUser(); if (StringUtils.isEmpty(newEmail)) { userForm.reject("email", "user.wrongEmail.alert"); } else { if (!StringUtils.equals(user.email, newEmail) && User.isEmailExist(newEmail)) { userForm.reject("email", "user.email.duplicate"); } } if (userForm.error("email") != null) { flash(Constants.WARNING, userForm.error("email").message()); return badRequest(edit.render(userForm, user)); } user.email = newEmail; user.name = newName; try { Long avatarId = Long.valueOf(userForm.data().get("avatarId")); if (avatarId != null) { Attachment attachment = Attachment.find.byId(avatarId); String primary = attachment.mimeType.split("/")[0].toLowerCase(); if (primary.equals("image")) { Attachment.deleteAll(currentUser().avatarAsResource()); attachment.moveTo(currentUser().avatarAsResource()); user.avatarUrl = routes.AttachmentApp.getFile(attachment.id).url(); } } } catch (NumberFormatException e) { } user.update(); return redirect( routes.UserApp.userInfo(user.loginId, DEFAULT_GROUP, DAYS_AGO, DEFAULT_SELECTED_TAB)); }
/** * 현재 사용자가 특정 프로젝트에서 탈퇴 * * @param userName 프로젝트 매니저의 로그인ID * @param projectName 프로젝트 이름 * @return */ public static Result leave(String userName, String projectName) { ProjectApp.deleteMember(userName, projectName, UserApp.currentUser().id); return redirect( routes.UserApp.userInfo( UserApp.currentUser().loginId, DEFAULT_GROUP, DAYS_AGO, DEFAULT_SELECTED_TAB)); }