...
|
...
|
@@ -13,6 +13,7 @@ import com.xkl.domain.Admin; |
|
|
import com.xkl.model.ResultModel;
|
|
|
import com.xkl.repository.AMPMachineRepository;
|
|
|
import com.xkl.repository.AdminRepository;
|
|
|
import com.xkl.security.SecurityTool;
|
|
|
import org.hibernate.validator.constraints.SafeHtml;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.http.HttpStatus;
|
...
|
...
|
@@ -39,29 +40,30 @@ public class UpSoftAccountController { |
|
|
@Autowired
|
|
|
private ITokenManager tokenManager;
|
|
|
|
|
|
private static final String UPSOFT_TOKEN_PREFIX = "UPSOFT_TOKEN";
|
|
|
private static final String UPSOFT_TOKEN_PREFIX = "UPSOFTTOKEN";
|
|
|
|
|
|
@RequestMapping(method = RequestMethod.POST)
|
|
|
@ApiOperation(value = "报告上传软件登录", notes = "login")
|
|
|
|
|
|
public ResponseEntity<ResultModel> login(@RequestParam String account, @RequestParam String password
|
|
|
, @RequestParam String ampserial, @RequestParam String ampkey) {
|
|
|
public ResponseEntity<ResultModel> login(@RequestParam String account, @RequestParam String password) {
|
|
|
// , @RequestParam String ampserial, @RequestParam String ampkey
|
|
|
Assert.notNull(account, "account can not be empty");
|
|
|
Assert.notNull(password, "password can not be empty");
|
|
|
Assert.notNull(ampserial, "ampserial can not be empty");
|
|
|
Assert.notNull(ampkey, "ampkey can not be empty");
|
|
|
|
|
|
AMPMachine ampMachine = ampMachineRepository.findBySecretKey(ampkey.trim());
|
|
|
if (ampMachine == null ||// 未找到密钥所对应的机器
|
|
|
!ampMachine.getAMPSerial().equals(ampserial) ||//amp序号不符合
|
|
|
ampMachine.getStatus() != 1) {//用户无效
|
|
|
return new ResponseEntity<>(ResultModel.error(ResultStatus.AMP_KEY_ERROR), HttpStatus.NOT_FOUND);
|
|
|
|
|
|
}
|
|
|
// Assert.notNull(ampserial, "ampserial can not be empty");
|
|
|
// Assert.notNull(ampkey, "ampkey can not be empty");
|
|
|
// AMPMachine ampMachine = ampMachineRepository.findBySecretKey(ampkey.trim());
|
|
|
// if (ampMachine == null ||// 未找到密钥所对应的机器
|
|
|
// !ampMachine.getAMPSerial().equals(ampserial) ||//amp序号不符合
|
|
|
// ampMachine.getStatus() != 1) {//用户无效
|
|
|
// return new ResponseEntity<>(ResultModel.error(ResultStatus.AMP_KEY_ERROR), HttpStatus.NOT_FOUND);
|
|
|
// }
|
|
|
|
|
|
Admin admin = adminRepository.findByAccount(account);
|
|
|
String salt = admin.getSalt();
|
|
|
String pass_in_db = admin.getPwd();
|
|
|
String calcuPass = SecurityTool.getPassword(account, password, salt);
|
|
|
if (admin == null || //未注册
|
|
|
!admin.getPwd().equals(password) ||//密码错误
|
|
|
!calcuPass.equals(pass_in_db) ||//密码错误
|
|
|
admin.getStatus() != 1) {//用户无效
|
|
|
//提示用户名或密码错误
|
|
|
return new ResponseEntity<>(ResultModel.error(ResultStatus.USERNAME_OR_PASSWORD_ERROR), HttpStatus.NOT_FOUND);
|
...
|
...
|
|