第二次修改

This commit is contained in:
liux 2024-06-11 10:36:28 +08:00
parent c5262c92b8
commit 23c53ee068
3 changed files with 83 additions and 66 deletions

View File

@ -0,0 +1,42 @@
package com.bonus.nxdt.energy.manager.config;
import com.bonus.nxdt.energy.manager.service.impl.UserDetailsServiceImpl;
import com.bonus.nxdt.energy.manager.utils.AesCbcUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.authentication.BadCredentialsException;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.authentication.dao.DaoAuthenticationProvider;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
/**
* 密码自定义校验
*/
@Slf4j
public class DecodePwdAuthenticationProvider extends DaoAuthenticationProvider {
public DecodePwdAuthenticationProvider(UserDetailsServiceImpl userDetailsService){
setUserDetailsService(userDetailsService);
}
@Override
protected void additionalAuthenticationChecks(UserDetails userDetails, UsernamePasswordAuthenticationToken authentication) throws AuthenticationException {
if (authentication.getCredentials() == null) {
this.logger.debug("Authentication failed: no credentials provided");
throw new BadCredentialsException(this.messages.getMessage("AbstractUserDetailsAuthenticationProvider.badCredentials", "Bad credentials"));
} else {
String presentedPassword = authentication.getCredentials().toString();
presentedPassword= AesCbcUtils.decrypt(presentedPassword);
BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
if (!passwordEncoder.matches(presentedPassword, userDetails.getPassword())) {
this.logger.debug("Authentication failed: password does not match stored value");
throw new BadCredentialsException(this.messages.getMessage("AbstractUserDetailsAuthenticationProvider.badCredentials", "Bad credentials"));
}
}
}
}

View File

@ -1,6 +1,6 @@
// var dataUrl ="http://218.21.27.6:1930/nxnyback/";
// var dataUrl ="http://127.0.0.1:1930/nxnyback/";
var dataUrl = "http://192.168.0.14:1930/nxnyback";
// var dataUrl ="http://140.210.195.210:1918/gzrbmw/";
// var dataUrl ="http://140.210.195.210:1920/gzrbmw/";
var dataUrl ="http://218.21.27.6:1930/nxnyback";
var token=localStorage.getItem('token');
$(function() {
var headHTML = document.getElementsByTagName('head')[0].innerHTML;

View File

@ -1,28 +1,29 @@
var ctxPath = getContextPath();
var dataPath = "http://192.168.0.14:1930/nxnyback";
// var dataUrl ="http://218.21.27.6:1930/nxnyback/";
// var dataUrl ="http://127.0.0.1:1930/nxnyback/";
// var dataPath = "http://192.168.0.176:1930/nxnyback";
var dataUrl ="http://218.21.27.6:1930/nxnyback/";
var aqEnnable = true;
//查看图片的路径
// var lookFile = "http://218.21.27.6:1999/nxnyback/statics"; //文件路径
var lookFile = "http://192.168.0.14:1930/nxnyback/statics"; //文件路径
var lookFile = "http://218.21.27.6:1999/nxnyback/statics"; //文件路径
//var lookFile = "http://192.168.0.14:1930/nxenergyweb/statics"; //文件路径
//kk file 测试环境地址
var filePreviewPathAll = "http://192.168.0.14:8012/onlinePreview?url=";
// var filePreviewPathAll = "http://218.21.27.6:8012/onlinePreview?url=";
//var filePreviewPathAll = "http://192.168.0.14:8012/onlinePreview?url=";
var filePreviewPathAll = "http://218.21.27.6:8012/onlinePreview?url=";
function getContextPath() {
var pathName = document.location.pathname;
var index = pathName.substr(1).indexOf("/");
return pathName.substr(0, index + 1);
var result = pathName.substr(0, index + 1);
return result;
}
var disphoto = ctxPath + '/statics/';
var filePath = ctxPath + '/statics';
function isNotEmpty(str) {
if (str != null && str !== 'null' && str !== '') {
if (str != null && str != 'null' && str != '') {
return true;
} else {
return false;
@ -36,7 +37,11 @@ function openFileWindows(url) {
}
function isEmpty(str) {
return str == null || str === 'null' || str === '';
if (str == null || str == 'null' || str == '') {
return true;
} else {
return false;
}
}
function choseType(str) {
@ -46,9 +51,13 @@ function choseType(str) {
return true;
} else if (str.indexOf("jpeg") > 0) {
return true;
} else return str.indexOf("gif") > 0;
} else if (str.indexOf("gif") > 0) {
return true;
} else {
return false;
}
}
};
function getTypeImg(str) {
if (str.toLowerCase().indexOf("xlsx") > 0 || str.toLowerCase().indexOf("xls") > 0) {
@ -155,12 +164,12 @@ function addSvg(svgId,addDivId) {
}
function getFirst(str) {
if(str ==null | str ==='null' | str === undefined | str ==='undefined' || str.length<1){
if(str ==null | str =='null' | str ==undefined | str=='undefined' | str.length<1){
return;
}
var x = str.substring(0,1);
var y = str.substring(1,str.length);
if(x === "/"){
if(x == "/"){
// str.substring(1,str.length);
console.log("str111=="+y)
return y;
@ -275,8 +284,10 @@ function checkPsidno(value)
}
// 不能是2月30号、4月31号、5月32号出生的吧
const date = new Date(year, month, 0) // 获取当月的最后一天
return !(day < 1 || day > date.getDate());
if (day < 1 || day > date.getDate()) {
return false
}
return true
}
// 4.18位号码校验生成的校验码
@ -301,8 +312,10 @@ function checkPsidno(value)
// 验证手机号码的正则
const phone_reg = function(num){
var num_reg = /^13[0-9]{1}[0-9]{8}$|15[0-9]{1}[0-9]{8}$|16[0-9]{1}[0-9]{8}$|18[0-9]{1}[0-9]{8}|17[0-9]{1}[0-9]{8}$|19[0-9]{1}[0-9]{8}$|14[0-9]{1}[0-9]{8}/;
return num_reg.test(num);
if(!num_reg.test(num)){
return false;
}
return true;
}
@ -320,7 +333,7 @@ function changeDivHeightById(divId,num) {
var height = $("#"+divId).outerHeight()
var lineNum = Math.ceil(num/6);
var ss = height*lineNum;
$('#'+divId).css("height", ss+"px");
$("#"+divId).css("height", ss+"px");
}
@ -335,57 +348,19 @@ function changeDivHeightByIdAndLine(divId,num,lineNum,type) {
if(num <= 0){
num =1;
}
let lineNum1;
const height = 160;
if(type ===1){
lineNum1 = Math.ceil((num+1)/lineNum);
var height = 160;
if(type ==1){
var lineNum = Math.ceil((num+1)/lineNum);
}else{
lineNum1 = Math.ceil(num/lineNum);
var lineNum = Math.ceil(num/lineNum);
}
const ss = height * lineNum1;
var ss = height*lineNum;
$("#"+divId).css("height", ss+"px");
}
const provinces = {
11: "北京",
12: "天津",
13: "河北",
14: "山西",
15: "内蒙古",
21: "辽宁",
22: "吉林",
23: "黑龙江",
31: "上海",
32: "江苏",
33: "浙江",
34: "安徽",
35: "福建",
36: "江西",
37: "山东",
41: "河南",
42: "湖北",
43: "湖南",
44: "广东",
45: "广西",
46: "海南",
50: "重庆",
51: "四川",
52: "贵州",
53: "云南",
54: "西藏",
61: "陕西",
62: "甘肃",
63: "青海",
64: "宁夏",
65: "新疆",
71: "台湾",
81: "香港",
82: "澳门",
91: "国外"
};
var provinces = { 11: "北京", 12: "天津", 13: "河北", 14: "山西", 15: "内蒙古", 21: "辽宁", 22: "吉林", 23: "黑龙江", 31: "上海", 32: "江苏", 33: "浙江", 34: "安徽", 35: "福建", 36: "江西", 37: "山东", 41: "河南", 42: "湖北", 43: "湖南", 44: "广东", 45: "广西", 46: "海南", 50: "重庆", 51: "四川", 52: "贵州", 53: "云南", 54: "西藏", 61: "陕西", 62: "甘肃", 63: "青海", 64: "宁夏", 65: "新疆", 71: "台湾", 81: "香港", 82: "澳门", 91: "国外" };
function getProvince(idNumber){
return provinces[parseInt(idNumber.substr(0, 2))];
}