登陆时无法登录

master
linjj 1 year ago
parent 4ac3deca8c
commit e0fe92fa24

@ -70,10 +70,10 @@ public class FontController {
@Autowired
private Power_DeptMapper powerDeptMapper;
@RequestMapping(value = "updatePassword")
public String updatePassword(Model model , HttpServletRequest request){
return"/userDir/updatePassword1";
}
// @RequestMapping(value = "updatePassword")
// public String updatePassword(Model model , HttpServletRequest request){
// return"/userDir/updatePassword1";
// }
@RequestMapping(value = "updatePass")

@ -26,6 +26,8 @@ import redis.clients.jedis.Jedis;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.text.SimpleDateFormat;
import java.util.*;
@ -154,12 +156,20 @@ public class LoginController {
ActionScopeUtils.setSessionAttribute("CURRENT_USER", user, Integer.valueOf(String.valueOf(TOKEN_EXPIRE_TIME)) / 1000);
String reg = "^(?![A-Za-z]+$)(?![A-Z\\d]+$)(?![A-Z\\W]+$)(?![a-z\\d]+$)(?![a-z\\W]+$)(?![\\d\\W]+$)\\S{8,20}$";
boolean msg = userPwd.matches(reg);
//判断是否存在ip限制
if (StringUtils.isNotBlank(user.getIp())){
//获取登录当前ip
String ipAddress = getAddressIp(request);
//将逗号隔开ip转为list
List<String> ips= Arrays.asList(user.getIp().split(","));
if (!loop(ips, ipAddress)){
return Msg.loginFail("当前用户不在允许登录ip,无法登录");
}
}
if (msg == false) {
String url = "http://" + SERVER_IP + ":" + SERVER_PORT + "/power" + "/font/updatePassword";
return Msg.success().add("url", url);
return Msg.success().add("url", "updatePassword");
} else {
String url = "http://" + SERVER_IP + ":" + SERVER_PORT + "/power/gatewayPage";
return Msg.success().add("url", url);
return Msg.success().add("url", "gatewayPage");
}
} else {
//登录失败
@ -201,6 +211,49 @@ public class LoginController {
}
//判断list中是否包含某元素
public static boolean loop(List<String> list, String value) {
for (String str : list) {
if (Objects.equals(str, value)) {
return true;
}
}
return false;
}
private String getAddressIp( HttpServletRequest request){
// 获取访问真实IP
String ipAddress = request.getHeader("x-forwarded-for");
if(ipAddress == null || ipAddress.length() == 0 || "unknown".equalsIgnoreCase(ipAddress)) {
ipAddress = request.getHeader("Proxy-Client-IP");
}
if(ipAddress == null || ipAddress.length() == 0 || "unknown".equalsIgnoreCase(ipAddress)) {
ipAddress = request.getHeader("WL-Proxy-Client-IP");
}
if(ipAddress == null || ipAddress.length() == 0 || "unknown".equalsIgnoreCase(ipAddress)) {
ipAddress = request.getRemoteAddr();
if(ipAddress.equals("127.0.0.1") || ipAddress.equals("0:0:0:0:0:0:0:1")){
//根据网卡取本机配置的IP
InetAddress inet=null;
try {
inet = InetAddress.getLocalHost();
} catch (UnknownHostException e) {
e.printStackTrace();
}
ipAddress= inet.getHostAddress();
}
}
//对于通过多个代理的情况第一个IP为客户端真实IP,多个IP按照','分割
if(ipAddress!=null && ipAddress.length()>15){ //"***.***.***.***".length() = 15
if(ipAddress.indexOf(",")>0){
ipAddress = ipAddress.substring(0,ipAddress.indexOf(","));
}
}
return ipAddress;
}
//获取session所剩时间
@RequestMapping(value = "getSessionRemainingTime", method = RequestMethod.GET, produces = {"text/json;charset=UTF-8"})
@ResponseBody

@ -78,6 +78,12 @@ public class PageController {
}
return "redirect:login";
}
@RequestMapping(value = "updatePassword")
public String updatePassword(Model model , HttpServletRequest request){
return"/userDir/updatePassword1";
}
@RequestMapping(value = "index")
public String index(Model model,HttpServletRequest request){
model.addAttribute("WEBSOCKET_URLHEAD",WEBSOCKET_URLHEAD);

@ -13,82 +13,102 @@
<script src="${path}/static/select2/select.js"></script>
<style type="text/css">
/*页头*/
.panel-heading{
.panel-heading {
padding: 0 16px;
}
hr{
margin:0;
hr {
margin: 0;
}
.form-group{
margin-left:15px;
.form-group {
margin-left: 15px;
}
/*模态框表单*/
.formDiv{
width:100%;
height:30px;
.formDiv {
width: 100%;
height: 30px;
}
.searchDiv{
margin-bottom:0px!important;
.searchDiv {
margin-bottom: 0px !important;
}
.control-label{
width:30%;
.control-label {
width: 30%;
text-align: right;
padding-top:2px;
padding-top: 2px;
}
.input{
width:50%;
float:left;
.input {
width: 50%;
float: left;
}
/*按钮组*/
.btns{
margin-top:5px;
.btns {
margin-top: 5px;
text-align: right;
margin-bottom: 5px;
}
/*模态框*/
.modal-header{
.modal-header {
text-align: center;
}
.modal-title{
.modal-title {
font-weight: bold;
}
.modelBtns{
.modelBtns {
text-align: center;
}
.modelBtn{
.modelBtn {
width: 74px;
margin-left: 38px;
margin-bottom: 16px;
}
.operBtns{
margin-left:10px;
.operBtns {
margin-left: 10px;
}
.tableDiv{
margin-left:14px;
.tableDiv {
margin-left: 14px;
}
.shortInput{
width:80px;
.shortInput {
width: 80px;
}
.sexInput{
width:70px;
.sexInput {
width: 70px;
}
.warningLabel{
margin-left:102px;
.warningLabel {
margin-left: 102px;
}
.warningDiv{
.warningDiv {
margin-left: 134px;
margin-top: -20px;
}
.hidden-xs{
.hidden-xs {
max-width: 250px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.form-group{
.form-group {
padding-top: 5px;
}
/*.dropdown {
width:50%!important;
}*/
@ -108,10 +128,10 @@
<label for="user_name">账号:</label>
<input type="text" class="form-control input-sm" id="user_name" maxlength="16"/>
</div>
<%-- <div class="form-group">
<label for="user_email">邮箱地址:</label>
<input type="text" class="form-control input-sm" id="user_email" maxlength="25"/>
</div>--%>
<%-- <div class="form-group">
<label for="user_email">邮箱地址:</label>
<input type="text" class="form-control input-sm" id="user_email" maxlength="25"/>
</div>--%>
<div class="form-group">
<label>所属角色:</label>
<div class=" form-group form-inline">
@ -164,7 +184,8 @@
</div>
</div>
<!-- 模态框Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" data-backdrop="static" data-keyboard="false">
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"
data-backdrop="static" data-keyboard="false">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
@ -176,45 +197,55 @@
<div class="formDiv">
<label class="control-label left">账号:</label>
<input type="hidden" id="userId" name="userId">
<input type="text" class="form-control input input-sm" id="re_userName" name="userName" maxlength="15">
<input type="text" class="form-control input input-sm" id="re_userName" name="userName"
maxlength="15">
</div>
<div class="formDiv" id="passwordDiv">
<label class="control-label left">密码:</label>
<input type="password" class="form-control input input-sm" readonly onfocus="this.removeAttribute('readonly');" id="re_userPwd" name="userPwd" maxlength="15" autocomplete="new-password">
<label class="control-label left">密码:</label>
<input type="password" class="form-control input input-sm" readonly
onfocus="this.removeAttribute('readonly');" id="re_userPwd" name="userPwd" maxlength="15"
autocomplete="new-password">
</div>
<div class="formDiv">
<label class="control-label left">姓名:</label>
<input type="text" class="form-control input input-sm" id="name" name="name" maxlength="15">
</div>
<div class="formDiv">
<label class="control-label left">性别:</label>
<label class="control-label left">性别:</label>
<select class="form-control input input-sm sexInput" id="re_userSex" name="userSex">
<option value="1" selected="selected">女</option>
<option value="0">男</option>
</select>
</div>
<div class="formDiv">
<label class="control-label left">年龄:</label>
<input type="number" class="form-control input input-sm sexInput" id="re_userAge" name="userAge" oninput="if(value.length>3)value=value.slice(0,3)">
<label class="control-label left">年龄:</label>
<input type="number" class="form-control input input-sm sexInput" id="re_userAge" name="userAge"
oninput="if(value.length>3)value=value.slice(0,3)">
</div>
<div class="formDiv">
<label class="control-label left">移动电话:</label>
<input type="text" class="form-control input input-sm" id="re_userTel" name="userTel" oninput="if(value.length>11)value=value.slice(0,11)">
<label class="control-label left">移动电话:</label>
<input type="text" class="form-control input input-sm" id="re_userTel" name="userTel"
oninput="if(value.length>11)value=value.slice(0,11)">
</div>
<div class="formDiv">
<label class="control-label left">邮箱地址:</label>
<input type="text" class="form-control input input-sm" id="re_userEmail" name="userEmail" maxlength="25">
<label class="control-label left">邮箱地址:</label>
<input type="text" class="form-control input input-sm" id="re_userEmail" name="userEmail"
maxlength="25">
</div>
<div class="formDiv">
<label class="control-label left">职位:</label>
<input type="text" class="form-control input input-sm" id="re_userPosition" name="userPosition" maxlength="25">
<label class="control-label left">职位:</label>
<input type="text" class="form-control input input-sm" id="re_userPosition" name="userPosition"
maxlength="25">
</div>
<div class="formDiv">
<label class="control-label left">所属科室:</label>
<div style="width:100%">
<select class="selectpicker" multiple id="deptId" name="deptId" style="max-height:400px!important;overflow:scroll;" data-live-search="true" data-actions-box="true">
<select class="selectpicker" multiple id="deptId" name="deptId"
style="max-height:400px!important;overflow:scroll;" data-live-search="true"
data-actions-box="true">
<c:forEach items="${depts}" var="dept">
<option value="${dept.deptId}" <c:if test="${deptId == dept.deptId}">selected</c:if>>${dept.deptName}</option>
<option value="${dept.deptId}"
<c:if test="${deptId == dept.deptId}">selected</c:if>>${dept.deptName}</option>
</c:forEach>
</select>
</div>
@ -222,29 +253,37 @@
<div class="formDiv" id="deptIdAdmin">
<label class="control-label left">质控科室:</label>
<div style="width:100%">
<select class="selectpicker" multiple id="deptIdQuality" name="deptIdQuality" style="max-height:400px!important;overflow:scroll;" data-live-search="true" data-actions-box="true">
<select class="selectpicker" multiple id="deptIdQuality" name="deptIdQuality"
style="max-height:400px!important;overflow:scroll;" data-live-search="true"
data-actions-box="true">
<c:forEach items="${depts}" var="dept">
<option value="${dept.deptId}" <c:if test="${deptId == dept.deptId}">selected</c:if>>${dept.deptName}</option>
<option value="${dept.deptId}"
<c:if test="${deptId == dept.deptId}">selected</c:if>>${dept.deptName}</option>
</c:forEach>
</select>
</div>
</div>
<div class="formDiv">
<label class="control-label left">所属角色:</label>
<label class="control-label left">所属角色:</label>
<select class="form-control input input-sm" id="re_roleId" name="roleId">
</select>
</div>
<div class="formDiv">
<label class="control-label left">有效否:</label>
<select class="form-control input input-sm shortInput" id="re_effective" name="effective">
<option value="1">是</option>
<option value="0">否</option>
</select>
</div>
<label class="control-label left">有效否:</label>
<select class="form-control input input-sm shortInput" id="re_effective" name="effective">
<option value="1">是</option>
<option value="0">否</option>
</select>
</div>
<div class="formDiv" id="invite">
<label class="control-label left">登录IP</label>
<input type="text" class="form-control input input-sm" id="ip" name="ip">
</div>
<div class="formDiv">
<label class="control-label left">备注:</label>
<textarea id="re_remark" class="form-control input input-sm" name="remark" maxlength="50"></textarea>
<label class="control-label left">备注:</label>
<textarea id="re_remark" class="form-control input input-sm" name="remark"
maxlength="50"></textarea>
</div>
</form>
@ -257,7 +296,8 @@
</div><!-- /.modal-dialog -->
</div>
<!-- 模态框Modal1 导入-->
<div class="modal fade" id="myModal1" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" data-backdrop="static" data-keyboard="false">
<div class="modal fade" id="myModal1" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"
data-backdrop="static" data-keyboard="false">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
@ -265,11 +305,13 @@
<h4 class="modal-title" id="myModalLabel1">导入信息</h4>
</div>
<div class="modal-body" style="height:380px">
<form method="POST" enctype="multipart/form-data"
id="form1">
<form method="POST" enctype="multipart/form-data"
id="form1">
<div class="formDiv">
<label class="control-label left">下载模板:</label>
<input class="btn btn-primary btn-sm" onclick="window.open('${path }/static/template/用户列表导入模板.xls');" type="button" value="下载模板">
<input class="btn btn-primary btn-sm"
onclick="window.open('${path }/static/template/用户列表导入模板.xls');" type="button"
value="下载模板">
</div>
<div class="formDiv">
<label for="re_effective" class="control-label left">选择文件:</label>

@ -103,10 +103,10 @@ function login() {
data: {userName: userName, userPwd: userPwd, rememberMe: rememberMe},
success: function (data) {
if (data.code == 100) {
window.location.href = 'gatewayPage';
window.location.href = data.extend.url;
}
if (data.code == 200){
toastr.warning(data.msg);
return toastr.warning(data.msg);
}
},
})

@ -58,6 +58,7 @@ $(function() {
setTimeout(function(){
window.location.reload();
},1000)
window.location.href = "login";
}else{
toastr.error("修改失败!");
}

@ -93,6 +93,10 @@ var form = '';
field:'powerDepts',
formatter:paramsMatter,
},
{
title:'ip',
field:'ip',
},
{
title:'是否有效',
field:'effective',
@ -321,6 +325,7 @@ function edit(id){
$("#txtTreeSelect1").val(data.powerDepts);
$("#deptIdQuality").val(data.deptIdQuality);
$("#deptIds").val(data.deptId);
$("#ip").val(data.ip);
if (data.deptId!="16"){
$("#deptIdAdmin").css("display","none")
}else if (data.deptId=="16"){
@ -333,17 +338,6 @@ function edit(id){
$("#re_roleId").find("option[value='"+data.roleId+"']").attr("selected",true);
$("#re_effective").find("option[value='"+data.effective+"']").attr("selected",true);
$("#re_remark").val(data.remark);
/*loadTree();
var deptIds = data.deptId;
if(deptIds != ''){
var deptIdSplit =deptIds.split(",");
for (var i = 0;i < deptIdSplit.length;i++){
if(deptIdSplit[i] != ''){
//选中节点
treeSelectNode(deptIdSplit[i]);
}
}
}*/
}
});
$('#myModal').modal('show');
@ -380,6 +374,8 @@ function drop(id) {
}
})
}
//新增框
function add() {
$("#re_userName").prop("readOnly",false);
@ -420,6 +416,7 @@ $('#btn_submit').click(function () {
var userPwd = $("#re_userPwd").val();
var deptIds = $("#deptId").val();
var roleId = $("#re_roleId").val();
var ip = $("#ip").val();
if(userName != ''){
if(userPwd != '' || $("#userId").val() != ''){
if(userPwd.length >= 6 || $("#userId").val() != ''){

@ -52,6 +52,16 @@ public class Power_User{
private String updater;
private String remark;
public String getIp() {
return ip;
}
public void setIp(String ip) {
this.ip = ip;
}
private String ip;
//使用deptId
private List<Power_Dept> powerDept;

@ -36,6 +36,16 @@ public class Power_UserVo extends Power_User {
private Integer showRecord;
private String ip;
public String getIp() {
return ip;
}
public void setIp(String ip) {
this.ip = ip;
}
@Override
public String getDeptCode() {
return deptCode;

@ -21,6 +21,7 @@
<result column="remark" jdbcType="VARCHAR" property="remark" />
<result column="role_name" jdbcType="VARCHAR" property="roleName" />
<result column="dict_id" jdbcType="INTEGER" property="dictId" />
<result column="ip" jdbcType="INTEGER" property="ip" />
</resultMap>
<resultMap id="BaseResultMapVo" type="com.manage.vo.User">
<id column="user_id" jdbcType="INTEGER" property="userId" />
@ -30,7 +31,7 @@
<result column="dept_code" jdbcType="VARCHAR" property="deptCode" />
</resultMap>
<sql id="Base_Column_List">
user_id, user_name,name, user_pwd, user_sex, user_age, user_tel, user_email, user_position,
user_id, user_name,name, user_pwd, user_sex, user_age, user_tel, user_email, user_position,ip,
role_id, dept_id, effective, create_date, creater, update_date, updater, remark,dept_id_quality
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
@ -213,6 +214,9 @@
</if>
<if test="updater != null and updater != ''">
updater = #{updater,jdbcType=VARCHAR},
</if>
<if test="ip != null and ip != ''">
ip = #{ip},
</if>
remark = #{remark,jdbcType=VARCHAR},
</set>
@ -256,6 +260,7 @@
power_user.update_date,
power_user.updater,
power_user.remark,
power_user.ip,
dept_id_quality,
GROUP_CONCAT(power_dept.dept_name) powerDepts
FROM
@ -294,6 +299,7 @@
power_user.create_date,
power_user.updater,
power_user.update_date,
power_user.ip,
power_role.role_name,
GROUP_CONCAT(power_dept.dept_name) powerDepts
FROM

@ -46,6 +46,14 @@ public class Msg {
}
public static Msg loginFail(String msg){
Msg result=new Msg();
result.setCode(200);
result.setMsg(msg);
return result;
}
public static Msg updatePassword(){
Msg result=new Msg();

Loading…
Cancel
Save