...
|
...
|
@@ -16,6 +16,7 @@ import com.xkl.repository.AMPMachineRepository; |
|
|
import com.xkl.repository.AdminRepository;
|
|
|
import com.xkl.security.AntiXSS;
|
|
|
import com.xkl.security.SecurityTool;
|
|
|
import com.xkl.service.ILoginService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.http.HttpStatus;
|
|
|
import org.springframework.http.ResponseEntity;
|
...
|
...
|
@@ -33,7 +34,8 @@ import org.springframework.web.bind.annotation.RestController; |
|
|
@Api("USPIH admin account login and logout")
|
|
|
@RequestMapping("/uspih/account")
|
|
|
public class AdminAccountController {
|
|
|
|
|
|
@Autowired
|
|
|
private ILoginService loginService;
|
|
|
@Autowired
|
|
|
private AdminRepository adminRepository;
|
|
|
|
...
|
...
|
@@ -50,24 +52,8 @@ public class AdminAccountController { |
|
|
Assert.notNull(account, "account can not be empty");
|
|
|
Assert.notNull(password, "password can not be empty");
|
|
|
|
|
|
|
|
|
XklAdminEntity admin = adminRepository.findByAccountAndStatus(account, Constants.STATUS_OK);
|
|
|
//未注册
|
|
|
if (admin == null) {
|
|
|
//提示用户名或密码错误
|
|
|
return new ResponseEntity<>(ResultModel.error(ResultStatus.USERNAME_OR_PASSWORD_ERROR), HttpStatus.OK);
|
|
|
}
|
|
|
String salt = admin.getSalt();
|
|
|
String adminType = Integer.toString(admin.getType());
|
|
|
String str = account + password + adminType + salt; // 构建待加密字符串
|
|
|
String calcuPass = SecurityTool.encode(SecurityTool.ALGORITHM_MD5, str);
|
|
|
|
|
|
String pass_in_db = admin.getPwd();
|
|
|
|
|
|
// String calcuPass = SecurityTool.getPassword(account, password, salt);
|
|
|
if (!calcuPass.equals(pass_in_db) ||//密码错误
|
|
|
admin.getStatus() != 1) {//用户无效
|
|
|
//提示用户名或密码错误
|
|
|
XklAdminEntity admin = loginService.checkAdmin(account, password);
|
|
|
if (admin == null) {//用户,密码错误
|
|
|
return new ResponseEntity<>(ResultModel.error(ResultStatus.USERNAME_OR_PASSWORD_ERROR), HttpStatus.OK);
|
|
|
}
|
|
|
|
...
|
...
|
@@ -94,27 +80,16 @@ public class AdminAccountController { |
|
|
public ResponseEntity<ResultModel> loginModPwd(@RequestParam String account, @RequestParam String password, @RequestParam String newpwd) {
|
|
|
Assert.notNull(account, "account can not be empty");
|
|
|
Assert.notNull(password, "password can not be empty");
|
|
|
Assert.notNull(newpwd, "newpwd can not be empty");
|
|
|
|
|
|
XklAdminEntity admin = adminRepository.findByAccountAndStatus(account, Constants.STATUS_OK);
|
|
|
//未注册
|
|
|
if (admin == null) {
|
|
|
//提示用户名或密码错误
|
|
|
XklAdminEntity admin = loginService.checkAdmin(account, password);
|
|
|
if (admin == null) {//用户,密码错误
|
|
|
return new ResponseEntity<>(ResultModel.error(ResultStatus.USERNAME_OR_PASSWORD_ERROR), HttpStatus.OK);
|
|
|
}
|
|
|
|
|
|
String salt = admin.getSalt();
|
|
|
String salt = SecurityTool.genSalt();
|
|
|
String adminType = Integer.toString(admin.getType());
|
|
|
String str = account + password + adminType + salt; // 构建待加密字符串
|
|
|
String calcuPass = SecurityTool.encode(SecurityTool.ALGORITHM_MD5, str);
|
|
|
|
|
|
String pass_in_db = admin.getPwd();
|
|
|
if (!calcuPass.equals(pass_in_db) ||//密码错误
|
|
|
admin.getStatus() != 1) {//用户无效
|
|
|
//提示用户名或密码错误
|
|
|
return new ResponseEntity<>(ResultModel.error(ResultStatus.USERNAME_OR_PASSWORD_ERROR), HttpStatus.OK);
|
|
|
}
|
|
|
salt = SecurityTool.genSalt();
|
|
|
str = account + newpwd + adminType + salt; // 构建待加密字符串
|
|
|
String str = account + newpwd + adminType + salt; // 构建待加密字符串
|
|
|
String pass2Db = SecurityTool.encode(SecurityTool.ALGORITHM_MD5, str);
|
|
|
admin.setPwd(pass2Db);
|
|
|
admin.setSalt(salt);
|
...
|
...
|
|