mirror of
https://gitee.com/dromara/MaxKey.git
synced 2026-05-16 21:40:42 +08:00
注册功能
This commit is contained in:
@@ -31,12 +31,15 @@ import org.maxkey.authn.support.rememberme.AbstractRemeberMeService;
|
||||
import org.maxkey.authn.support.socialsignon.service.SocialSignOnProviderService;
|
||||
import org.maxkey.authn.support.wsfederation.WsFederationConstants;
|
||||
import org.maxkey.configuration.ApplicationConfig;
|
||||
import org.maxkey.constants.ConstantsOperateMessage;
|
||||
import org.maxkey.constants.ConstantsStatus;
|
||||
import org.maxkey.crypto.password.opt.AbstractOptAuthn;
|
||||
import org.maxkey.domain.UserInfo;
|
||||
import org.maxkey.persistence.service.UserInfoService;
|
||||
import org.maxkey.util.StringUtils;
|
||||
import org.maxkey.web.WebConstants;
|
||||
import org.maxkey.web.WebContext;
|
||||
import org.maxkey.web.message.Message;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -222,4 +225,51 @@ public class LoginEndpoint {
|
||||
|
||||
return "fail";
|
||||
}
|
||||
|
||||
/**
|
||||
* view register
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value={"/register"})
|
||||
public ModelAndView register(HttpServletRequest request,HttpServletResponse response) {
|
||||
|
||||
_logger.debug("LoginController /register.");
|
||||
ModelAndView modelAndView = new ModelAndView("registration/register");
|
||||
Object loginErrorMessage=WebContext.getAttribute(WebConstants.LOGIN_ERROR_SESSION_MESSAGE);
|
||||
modelAndView.addObject("loginErrorMessage", loginErrorMessage==null?"":loginErrorMessage);
|
||||
WebContext.removeAttribute(WebConstants.LOGIN_ERROR_SESSION_MESSAGE);
|
||||
return modelAndView;
|
||||
}
|
||||
|
||||
@RequestMapping(value={"/registeron"})
|
||||
@ResponseBody
|
||||
public Message registeron(UserInfo userInfo,@RequestParam String emailMobile) throws ServletException, IOException {
|
||||
if(StringUtils.isNullOrBlank(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.queryUserInfoByEmailMobile(emailMobile);
|
||||
if(temp!=null) {
|
||||
return new Message(WebContext.getI18nValue("register.emailMobile.exist"),"1");
|
||||
}
|
||||
|
||||
temp=userInfoService.loadByUsername(userInfo.getUsername());
|
||||
if(temp!=null) {
|
||||
return new Message(WebContext.getI18nValue("register.user.error"),"1");
|
||||
}
|
||||
userInfo.setStatus(ConstantsStatus.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");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user