|
|
@@ -8,6 +8,8 @@ import com.uas.platform.b2bManage.model.User;
|
|
|
import com.uas.platform.b2bManage.page.exception.IllegalOperatorException;
|
|
|
import com.uas.platform.b2bManage.service.UseLogService;
|
|
|
import com.uas.platform.b2bManage.service.UserService;
|
|
|
+import com.uas.platform.b2bManage.support.MyException;
|
|
|
+import com.uas.platform.b2bManage.support.SecurityConstant;
|
|
|
import com.uas.platform.b2bManage.web.BaseController;
|
|
|
import com.uas.platform.core.util.AgentUtils;
|
|
|
import com.uas.platform.core.util.encry.Md5Utils;
|
|
|
@@ -20,6 +22,7 @@ import org.springframework.web.bind.support.SessionStatus;
|
|
|
import javax.servlet.ServletException;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
+import javax.servlet.http.HttpSession;
|
|
|
import java.io.IOException;
|
|
|
import java.io.UnsupportedEncodingException;
|
|
|
|
|
|
@@ -48,35 +51,59 @@ public class AccountController extends BaseController {
|
|
|
return success(SystemSession.getUser());
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 登录
|
|
|
- *
|
|
|
- */
|
|
|
+ /**
|
|
|
+ * 登录
|
|
|
+ *
|
|
|
+ * @param userName 用户名 手机或邮箱
|
|
|
+ * @param passWord 密码 明文
|
|
|
+ * @return ModelMap
|
|
|
+ * <pre>
|
|
|
+ * success : 是否成功
|
|
|
+ * content : 用户信息
|
|
|
+ * url : 访问路径
|
|
|
+ * </pre>
|
|
|
+ * @throws IllegalAccessException
|
|
|
+ * @throws UnsupportedEncodingException
|
|
|
+ */
|
|
|
@RequestMapping(value = "/login", method = RequestMethod.POST)
|
|
|
- public void login(String userName, String passWord) throws IllegalAccessException, UnsupportedEncodingException {
|
|
|
+ public ModelMap login(String userName, String passWord) throws IllegalAccessException, UnsupportedEncodingException {
|
|
|
userService.login(userName.trim(), passWord.trim(), request, response);
|
|
|
useLogService.appendLog(UseType.LOGIN.code(), null, AgentUtils.getIp(request));
|
|
|
+ ModelMap map = new ModelMap();
|
|
|
+ User user = SystemSession.getUser();
|
|
|
+ String returnUrl = null != user ? SecurityConstant.INDEX_URL : SecurityConstant.LOGIN_URL;
|
|
|
+ boolean logSuccess = null != user ? true : false;
|
|
|
+ map.put("success", logSuccess);
|
|
|
+ map.put("content", user);
|
|
|
+ map.put("url", returnUrl);
|
|
|
+ return map;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 退出
|
|
|
- *
|
|
|
- * @throws IOException
|
|
|
- */
|
|
|
+ /**
|
|
|
+ * 退出
|
|
|
+ *
|
|
|
+ * @param sessionStatus session状态
|
|
|
+ * @param session session
|
|
|
+ * @return 访问路径
|
|
|
+ * @throws IOException IO异常
|
|
|
+ */
|
|
|
@RequestMapping(value = "/logout", method = RequestMethod.POST)
|
|
|
- public ModelMap logout(SessionStatus sessionStatus) throws IOException {
|
|
|
+ public ModelMap logout(SessionStatus sessionStatus, HttpSession session) throws IOException {
|
|
|
SystemSession.clear();
|
|
|
- request.getSession().invalidate();
|
|
|
+ session.invalidate();
|
|
|
sessionStatus.setComplete();
|
|
|
- useLogService.appendLog(UseType.LOGOUT.code(), null, AgentUtils.getIp(request));
|
|
|
- return success();
|
|
|
+ User user = SystemSession.getUser();
|
|
|
+ if (null != user) {
|
|
|
+ logout(sessionStatus, session);
|
|
|
+ }
|
|
|
+ return new ModelMap("url", SecurityConstant.LOGIN_URL);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 检验手机号
|
|
|
*
|
|
|
* @param tel 手机号码
|
|
|
- * @return
|
|
|
+ * @return ModelMap success true
|
|
|
*/
|
|
|
@RequestMapping(value = "/valid/tel", method = RequestMethod.POST)
|
|
|
public ModelMap validTel(String tel) {
|
|
|
@@ -91,7 +118,7 @@ public class AccountController extends BaseController {
|
|
|
* 检验邮箱
|
|
|
*
|
|
|
* @param email 邮箱
|
|
|
- * @return
|
|
|
+ * @return ModelMap success true
|
|
|
*/
|
|
|
@RequestMapping(value = "/valid/email", method = RequestMethod.POST)
|
|
|
public ModelMap validEmail(String email) {
|
|
|
@@ -107,7 +134,11 @@ public class AccountController extends BaseController {
|
|
|
* 注册
|
|
|
*
|
|
|
* @param user 用户信息
|
|
|
- * @return
|
|
|
+ * @return ModelMap
|
|
|
+ * <pre>
|
|
|
+ * success: true
|
|
|
+ * content: user
|
|
|
+ * </pre>
|
|
|
*/
|
|
|
@RequestMapping(value = "/register", method = RequestMethod.POST)
|
|
|
public ModelMap register(User user) {
|
|
|
@@ -122,7 +153,9 @@ public class AccountController extends BaseController {
|
|
|
if (StringUtils.isEmpty(email)) {
|
|
|
throw new IllegalOperatorException("请输入邮箱地址");
|
|
|
}
|
|
|
- if (email.contains("=")) {
|
|
|
+ // 等于符号
|
|
|
+ String equalSymbol = "=";
|
|
|
+ if (email.contains(equalSymbol)) {
|
|
|
email = email.replace("=", "");
|
|
|
}
|
|
|
email = email + Constant.EMAIL_SUFFIX;
|
|
|
@@ -133,7 +166,7 @@ public class AccountController extends BaseController {
|
|
|
* 通过链接修改密码
|
|
|
*/
|
|
|
@RequestMapping(value = "/resetPwd/url", method = RequestMethod.GET)
|
|
|
- public void resetPwdByUrl(String secretKey, HttpServletResponse response, HttpServletRequest request) throws IOException, NotFoundException, ServletException {
|
|
|
+ public void resetPwdByUrl(String secretKey, HttpServletResponse response, HttpServletRequest request) throws IOException, MyException, ServletException {
|
|
|
userService.resetPwd(secretKey, response, request);
|
|
|
}
|
|
|
|