1
0
mirror of https://gitee.com/bookshelfplus/bookshelfplus synced 2025-09-05 00:21:38 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee

密码加密放在后台进行

This commit is contained in:
2022-04-01 18:03:16 +08:00
parent d3c9ba10c4
commit b27b709cbf
4 changed files with 100 additions and 11 deletions

View File

@@ -2,6 +2,7 @@ package plus.bookshelf.Controller.Controller;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.codec.digest.DigestUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
@@ -11,7 +12,6 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import plus.bookshelf.Common.Response.CommonReturnType;
import plus.bookshelf.Common.SessionManager.LocalSessionManager;
import plus.bookshelf.Common.SessionManager.SessionManager;
import plus.bookshelf.Controller.VO.UserVO;
import plus.bookshelf.Service.Impl.UserServiceImpl;
import plus.bookshelf.Service.Model.UserModel;
@@ -24,14 +24,15 @@ public class UserController extends BaseController {
@Autowired
UserServiceImpl userService;
@ApiOperation(value = "用户登录", notes = "传入用户名,以及密码的MD5值,进行登录")
@ApiOperation(value = "用户登录", notes = "传入用户名,以及密码明文后台计算密码SHA1值,进行登录")
@RequestMapping(value = "login", method = {RequestMethod.POST}, consumes = {CONTENT_TYPE_FORMED})
@ResponseBody
public CommonReturnType login(@RequestParam(value = "username") String username,
@RequestParam(value = "encryptpwd") String encryptPwd) {
if (username == null || encryptPwd == null) {
@RequestParam(value = "password") String password) {
if (username == null || password == null) {
return null;
}
String encryptPwd = DigestUtils.sha1Hex(password);
UserModel userModel = userService.userLogin(username, encryptPwd);
UserVO userVO = convertFromService(userModel);
@@ -42,14 +43,16 @@ public class UserController extends BaseController {
return CommonReturnType.create(userVO);
}
// @ApiOperation(value = "用户注册", notes = "传入用户名,以及密码的MD5值,进行注册")
// @ApiOperation(value = "用户注册", notes = "传入用户名,以及密码明文后台计算密码SHA1值,进行注册")
// @RequestMapping(value = "register", method = {RequestMethod.POST}, consumes = {CONTENT_TYPE_FORMED})
// @ResponseBody
// public CommonReturnType register(@RequestParam(value = "username") String username,
// @RequestParam(value = "encryptpwd") String encryptPwd) {
// if (username == null || encryptPwd == null) {
// @RequestParam(value = "password") String password) {
// if (username == null || password == null) {
// return null;
// }
// String encryptPwd = DigestUtils.sha1Hex(password);
//
// UserModel userModel = userService.userRegister(username, encryptPwd);
// UserVO userVO = convertFromService(userModel);
// return CommonReturnType.create(userVO);