use of com.ngtesting.platform.entity.TestUser in project ngtesting-platform by aaronchen2k.
the class AccountAction method loginWithVcode.
@AuthPassport(validate = false)
@RequestMapping(value = "loginWithVcode", method = RequestMethod.POST)
@ResponseBody
public Map<String, Object> loginWithVcode(HttpServletRequest request, @RequestBody JSONObject json) {
Map<String, Object> ret = new HashMap<String, Object>();
String vcode = json.getString("vcode");
TestUser user = accountService.resetPasswordPers(vcode, null);
if (user != null) {
UserVo userVo = userService.genVo(user);
request.getSession().setAttribute(Constant.HTTP_SESSION_USER_KEY, userVo);
ret.put("profile", userVo);
ret.put("token", user.getToken());
ret.put("code", RespCode.SUCCESS.getCode());
} else {
ret.put("code", RespCode.BIZ_FAIL.getCode());
ret.put("msg", "登录失败");
}
return ret;
}
use of com.ngtesting.platform.entity.TestUser in project ngtesting-platform by aaronchen2k.
the class AccountAction method login.
@AuthPassport(validate = false)
@RequestMapping(value = "login", method = RequestMethod.POST)
@ResponseBody
public Map<String, Object> login(HttpServletRequest request, @RequestBody JSONObject json) {
Map<String, Object> ret = new HashMap<String, Object>();
String email = json.getString("email");
String password = json.getString("password");
boolean rememberMe = json.getBoolean("rememberMe") != null ? json.getBoolean("rememberMe") : false;
TestUser user = accountService.loginPers(email, password, rememberMe);
if (user != null) {
UserVo userVo = userService.genVo(user);
request.getSession().setAttribute(Constant.HTTP_SESSION_USER_KEY, userVo);
ret.put("profile", userVo);
ret.put("token", user.getToken());
ret.put("code", RespCode.SUCCESS.getCode());
} else {
ret.put("code", RespCode.BIZ_FAIL.getCode());
ret.put("msg", "登录失败");
}
return ret;
}
use of com.ngtesting.platform.entity.TestUser in project ngtesting-platform by aaronchen2k.
the class UserServiceImpl method invitePers.
@Override
public TestUser invitePers(UserVo userVo, UserVo newUserVo, List<RelationOrgGroupUserVo> relations) {
Long orgId = userVo.getDefaultOrgId();
Long prjId = userVo.getDefaultPrjId();
String prjName = userVo.getDefaultPrjName();
TestUser existUser = accountService.getByEmail(newUserVo.getEmail());
boolean isNew;
TestUser userPo;
if (existUser != null) {
isNew = false;
userPo = existUser;
} else {
isNew = true;
userPo = new TestUser();
userPo.setDefaultOrgId(orgId);
userPo.setName(newUserVo.getName());
userPo.setPhone(newUserVo.getPhone());
userPo.setEmail(newUserVo.getEmail());
userPo.setDisabled(newUserVo.getDisabled());
userPo.setAvatar("upload/sample/user/avatar.png");
userPo.setDefaultOrgId(userVo.getDefaultOrgId());
userPo.setDefaultPrjId(userVo.getDefaultPrjId());
userPo.setName(newUserVo.getName());
saveOrUpdate(userPo);
}
TestOrg org = (TestOrg) get(TestOrg.class, orgId);
if (!contains(org.getUserSet(), userPo.getId())) {
// 不在组里
org.getUserSet().add(userPo);
saveOrUpdate(org);
projectService.getHistoryPers(orgId, userPo.getId(), prjId, prjName);
orgGroupUserService.saveRelations(relations);
String sys = PropertyConfig.getConfig("sys.name");
Map<String, String> map = new HashMap<String, String>();
map.put("user", userPo.getName() + "(" + userPo.getEmail() + ")");
map.put("name", userPo.getName());
map.put("sys", sys);
String url;
if (isNew) {
TestVerifyCode verifyCode = accountService.genVerifyCodePers(userPo.getId());
url = PropertyConfig.getConfig("url.reset.password") + "/" + verifyCode.getCode();
} else {
url = PropertyConfig.getConfig("url.login");
}
map.put("url", url);
mailService.sendTemplateMail("来自[" + sys + "]的邀请", "invite-user.ftl", newUserVo.getEmail(), map);
return userPo;
} else {
return null;
}
}
use of com.ngtesting.platform.entity.TestUser in project ngtesting-platform by aaronchen2k.
the class UserServiceImpl method remove.
@Override
public boolean remove(Long userId, Long orgId) {
TestUser po = (TestUser) get(TestUser.class, userId);
po.setDeleted(true);
saveOrUpdate(po);
return true;
}
use of com.ngtesting.platform.entity.TestUser in project ngtesting-platform by aaronchen2k.
the class UserServiceImpl method genVos.
@Override
public List<UserVo> genVos(List<TestUser> pos) {
List<UserVo> vos = new LinkedList<UserVo>();
for (TestUser po : pos) {
UserVo vo = genVo(po);
vos.add(vo);
}
return vos;
}
Aggregations