Commit f3d0d8cf authored by Quxl's avatar Quxl

找回密码BUG

parent e5b7393e
......@@ -9,6 +9,7 @@ import javax.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
......@@ -83,7 +84,12 @@ public class MemberOpenApiController {
XException.assertNotBlank(messages.get("err.email_null"), email);
int code = (int) ((Math.random() * 9 + 1) * 10000000);
String password = String.valueOf(code);
Fc_member member = memberService.getMemberByEmail(email);
Fc_member member = null;
try {
member = memberService.getMemberByEmail(email);
} catch (EmptyResultDataAccessException e) {
throw new XException(messages.get("err.user_not_exists"));
}
String encodePwd = Common.encodePassword(password, member.getSalt());
memberService.resetPassword(member.getId(), encodePwd);
String name = member.getUsername();
......
......@@ -23,5 +23,7 @@ public class Common {
public static void main(String[] args) {
System.out.println(encodePassword("123456", "5e0vt0"));
System.out.println(getGenerateString(6));
}
}
......@@ -7,6 +7,7 @@ err.user_disabled=User disabled
err.user_pwd_err=User or password error
err.user_pwd_null=User and passowrd can not be null
err.user_exists=User already exists
err.user_not_exists=User does not exists
err.email_null=The mailbox can not be empty
err.name_null=The username can not be empty
err.pwd_null=The password can not be empty
......
......@@ -7,6 +7,7 @@ err.user_disabled=\u7528\u6237\u5DF2\u7ECF\u7981\u7528
err.user_pwd_err=\u7528\u6237\u6216\u5BC6\u7801\u9519\u8BEF
err.user_pwd_null=\u7528\u6237\u540D\u548C\u5BC6\u7801\u4E0D\u80FD\u4E3A\u7A7A
err.user_exists=\u7528\u6237\u5DF2\u5B58\u5728
err.user_not_exists=\u7528\u6237\u4E0D\u5B58\u5728
err.email_null=\u90AE\u7BB1\u4E0D\u80FD\u4E3A\u7A7A
err.name_null=\u59D3\u540D\u4E0D\u80FD\u4E3A\u7A7A
err.pwd_null=\u5BC6\u7801\u4E0D\u80FD\u4E3A\u7A7A
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment