use of org.maxkey.entity.UserInfo in project MaxKey by dromara.
the class OneTimePasswordController method genhotp.
@RequestMapping(value = { "gen/hotp" })
public ModelAndView genhotp() {
UserInfo userInfo = WebContext.getUserInfo();
byte[] byteSharedSecret = OtpSecret.generate(otpKeyUriFormat.getCrypto());
String sharedSecret = Base32Utils.encode(byteSharedSecret);
sharedSecret = passwordReciprocal.encode(sharedSecret);
userInfo.setSharedSecret(sharedSecret);
userInfo.setSharedCounter("0");
userInfoService.updateSharedSecret(userInfo);
WebContext.setUserInfo(userInfo);
return WebContext.redirect("/safe/otp/hotp");
}
use of org.maxkey.entity.UserInfo in project MaxKey by dromara.
the class OneTimePasswordController method gencounterbased.
@RequestMapping(value = { "gen/counterbased" })
public ModelAndView gencounterbased() {
UserInfo userInfo = WebContext.getUserInfo();
byte[] byteSharedSecret = OtpSecret.generate(otpKeyUriFormat.getCrypto());
String sharedSecret = Base32Utils.encode(byteSharedSecret);
sharedSecret = passwordReciprocal.encode(sharedSecret);
userInfo.setSharedSecret(sharedSecret);
userInfo.setSharedCounter("0");
userInfoService.updateSharedSecret(userInfo);
WebContext.setUserInfo(userInfo);
return WebContext.redirect("/safe/otp/counterbased");
}
use of org.maxkey.entity.UserInfo in project MaxKey by dromara.
the class ProfileController method forwardBasic.
@RequestMapping(value = { "/myProfile" })
public ModelAndView forwardBasic() {
ModelAndView modelAndView = new ModelAndView("profile/myProfile");
UserInfo userInfo = userInfoService.findByUsername(WebContext.getUserInfo().getUsername());
userInfo.transPictureBase64();
// HashMap<String,Object>extraAttributeMap=new HashMap<String,Object>();
// extraAttributeMap=(HashMap<String,Object>)JsonUtils.json2Object(userInfo.getExtraAttribute(),extraAttributeMap);
// modelAndView.addObject("extraAttributeMap", extraAttributeMap);
// _logger.info("extraAttributeMap : "+extraAttributeMap);
//
modelAndView.addObject("model", userInfo);
return modelAndView;
}
use of org.maxkey.entity.UserInfo in project MaxKey by dromara.
the class RegisterController method registeron.
// 直接注册
@RequestMapping(value = { "/registeron" })
@ResponseBody
public Message registeron(UserInfo userInfo, @RequestParam String emailMobile) throws ServletException, IOException {
if (StringUtils.isEmpty(emailMobile)) {
return new Message(WebContext.getI18nValue("register.emailMobile.error"), "1");
}
if (StringUtils.isValidEmail(emailMobile)) {
userInfo.setEmail(emailMobile);
}
if (StringUtils.isValidMobileNo(emailMobile)) {
userInfo.setMobile(emailMobile);
}
if (!(StringUtils.isValidEmail(emailMobile) || StringUtils.isValidMobileNo(emailMobile))) {
return new Message(WebContext.getI18nValue("register.emailMobile.error"), "1");
}
UserInfo temp = userInfoService.findByEmailMobile(emailMobile);
if (temp != null) {
return new Message(WebContext.getI18nValue("register.emailMobile.exist"), "1");
}
temp = userInfoService.findByUsername(userInfo.getUsername());
if (temp != null) {
return new Message(WebContext.getI18nValue("register.user.error"), "1");
}
// default InstId
if (StringUtils.isEmpty(userInfo.getInstId())) {
userInfo.setInstId("1");
}
userInfo.setStatus(ConstsStatus.ACTIVE);
if (userInfoService.insert(userInfo)) {
return new Message(WebContext.getI18nValue("login.text.register.success"), "0");
}
return new Message(WebContext.getI18nValue("login.text.register.error"), "1");
}
use of org.maxkey.entity.UserInfo in project MaxKey by dromara.
the class SafeController method changeInitPassword.
@RequestMapping(value = "/changeInitPassword")
public ModelAndView changeInitPassword(@RequestParam(value = "oldPassword", required = false) String oldPassword, @RequestParam(value = "newPassword", required = false) String newPassword, @RequestParam(value = "confirmPassword", required = false) String confirmPassword) {
ModelAndView modelAndView = new ModelAndView("passwordInitial");
if (newPassword == null || newPassword.equals("")) {
} else if (userInfoService.changePassword(oldPassword, newPassword, confirmPassword, ConstsPasswordSetType.PASSWORD_NORMAL)) {
WebContext.getSession().setAttribute(WebConstants.CURRENT_USER_PASSWORD_SET_TYPE, ConstsPasswordSetType.PASSWORD_NORMAL);
return WebContext.redirect("/index");
}
Object errorMessage = WebContext.getAttribute(PasswordPolicyValidator.PASSWORD_POLICY_VALIDATE_RESULT);
modelAndView.addObject("errorMessage", errorMessage == null ? "" : errorMessage);
UserInfo userInfo = WebContext.getUserInfo();
modelAndView.addObject("model", userInfo);
return modelAndView;
}
Aggregations