use of org.neusoft.neubbs.dto.ApiJsonDTO in project neubbs by nuitcoder.
the class AccountController method logoutAccount.
/**
* 注销
*
* @return ApiJsonDTO 接口 JSON 传输对象
*/
@LoginAuthorization
@RequestMapping(value = "/logout", method = RequestMethod.GET)
public ApiJsonDTO logoutAccount() {
httpService.removeCookie(ParamConst.AUTHENTICATION);
httpService.decreaseOnlineLoginUserNumber();
return new ApiJsonDTO().success();
}
use of org.neusoft.neubbs.dto.ApiJsonDTO in project neubbs by nuitcoder.
the class AccountController method activateAccount.
/**
* 激活账户
* - 发送激活 mail
*
* @param requestBodyParamsMap request-body 内 JSON 数据
* @return ApiJsonDTO 接口 JSON 传输对象
*/
@RequestMapping(value = "/activate", method = RequestMethod.POST, consumes = "application/json")
public ApiJsonDTO activateAccount(@RequestBody Map<String, Object> requestBodyParamsMap) {
String email = (String) requestBodyParamsMap.get(ParamConst.EMAIL);
validationService.check(ParamConst.EMAIL, email);
userService.confirmUserActivatedByEmail(email);
// 60s send email interval
long remainAllowSendEmailInterval = cacheService.getEmailKeyExpireTime(email);
if (remainAllowSendEmailInterval != SetConst.EXPIRE_TIME_REDIS_NO_EXIST_KEY) {
Map<String, Object> timerMap = new HashMap<>(SetConst.SIZE_ONE);
timerMap.put(ParamConst.TIMER, remainAllowSendEmailInterval / SetConst.TIME_THOUSAND_MS);
return new ApiJsonDTO().fail().message(ApiMessage.WAIT_TIMER).model(timerMap);
}
// start another thread to send mail
emailService.sendAccountActivateMail(email, secretService.generateValidateEmailToken(email));
// set user send email 60s interval
cacheService.saveUserEmailKey(email);
return new ApiJsonDTO().success();
}
use of org.neusoft.neubbs.dto.ApiJsonDTO in project neubbs by nuitcoder.
the class AccountController method registerAccount.
/**
* 注册
*
* @param requestBodyParamsMap request-body 内 JSON 数据
* @return ApiJsonDTO 接口 JSON 传输对象
*/
@RequestMapping(value = "/register", method = RequestMethod.POST, consumes = "application/json")
public ApiJsonDTO registerAccount(@RequestBody Map<String, Object> requestBodyParamsMap) {
String username = (String) requestBodyParamsMap.get(ParamConst.USERNAME);
String password = (String) requestBodyParamsMap.get(ParamConst.PASSWORD);
String email = (String) requestBodyParamsMap.get(ParamConst.EMAIL);
validationService.check(ParamConst.USERNAME, username).check(ParamConst.PASSWORD, password).check(ParamConst.EMAIL, email);
// database register user
UserDO newRegisterUser = userService.registerUser(username, password, email);
// create user person directory on cloud ftp server
ftpService.createUserPersonalDirectory(newRegisterUser);
return new ApiJsonDTO().success().model(userService.getUserInfoModelMap(newRegisterUser));
}
Aggregations