|
|
@@ -1,5 +1,6 @@
|
|
|
package com.uas.sso.controller;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
import com.uas.sso.core.Const;
|
|
|
import com.uas.sso.core.Status;
|
|
|
import com.uas.sso.entity.*;
|
|
|
@@ -11,10 +12,7 @@ import com.uas.sso.util.CollectionUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.ui.ModelMap;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
-import org.springframework.web.bind.annotation.RequestParam;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
@@ -70,6 +68,13 @@ public class ChangeAdminController extends BaseController {
|
|
|
data.put("mobile", Status.AUTHENTICATED.getCode() == user.getMobileValidCode() ? user.getMobile() : null);
|
|
|
data.put("email", Status.AUTHENTICATED.getCode() == user.getEmailValidCode() ? user.getEmail() : null);
|
|
|
data.put("questions", !CollectionUtils.isEmpty(user.getQuestions()) ? user.getQuestions() : null);
|
|
|
+ if (!CollectionUtils.isEmpty(user.getQuestions())) {
|
|
|
+ Map<Long, String> userAnswer = new HashMap<>(user.getQuestions().size());
|
|
|
+ for (UserQuestion question : user.getQuestions()) {
|
|
|
+ userAnswer.put(question.getId(), question.getAnswer());
|
|
|
+ }
|
|
|
+ request.getSession().setAttribute("answers", userAnswer);
|
|
|
+ }
|
|
|
request.getSession().setAttribute("user", user);
|
|
|
return success(data);
|
|
|
}
|
|
|
@@ -135,7 +140,7 @@ public class ChangeAdminController extends BaseController {
|
|
|
data.put("vipName", userAccount.getVipName());
|
|
|
data.put("type", "更换管理员");
|
|
|
// TODO 邮件认证地址
|
|
|
- data.put("url", getFrontUrl() + "/sso/resetPwd/check/question?token="+existToken.getId());
|
|
|
+ data.put("url", getFrontUrl() + "/change/changeManagerSecondStep?token="+existToken.getId());
|
|
|
|
|
|
// 发送邮件
|
|
|
String email = userAccount.getEmail();
|
|
|
@@ -186,13 +191,14 @@ public class ChangeAdminController extends BaseController {
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "/check/question", method = RequestMethod.POST)
|
|
|
- public ModelMap checkByQuestion(List<Map<String, Object>> answers) {
|
|
|
+ public ModelMap checkByQuestion(String answers) {
|
|
|
UserAccount userAccount = SystemSession.getUserAccount();
|
|
|
+ List<Map> jsonAnswer = JSON.parseArray(answers, Map.class);
|
|
|
|
|
|
// 校验密保答案
|
|
|
Map<Long, String> userAnswer = (Map<Long, String>) request.getSession().getAttribute("answers");
|
|
|
- for (Map<String, Object> answer : answers) {
|
|
|
- if (!answer.get("answer").equals(userAnswer.get(answer.get("id")))){
|
|
|
+ for (Map<String, Object> answer : jsonAnswer) {
|
|
|
+ if (!answer.get("answer").equals(userAnswer.get(Long.valueOf(answer.get("id").toString())))){
|
|
|
return error("答案错误");
|
|
|
}
|
|
|
}
|