Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
aserver
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
15所TongWeb
aserver
Commits
2bfe1e9d
Commit
2bfe1e9d
authored
Nov 26, 2020
by
李德才
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
更换登录方法获取用户和系统的方式
parent
7ef9bc89
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
17 deletions
+20
-17
IndexController.java
.../java/com/archser/aserver/controller/IndexController.java
+20
-17
No files found.
src/main/java/com/archser/aserver/controller/IndexController.java
View file @
2bfe1e9d
package
com
.
archser
.
aserver
.
controller
;
package
com
.
archser
.
aserver
.
controller
;
import
com.archser.aserver.util.redis.InfoSystem
;
import
com.archser.aserver.util.redis.InfoUser
;
import
com.archser.aserver.util.redis.RedisConvert
;
import
com.jfinal.kit.JsonKit
;
import
java.math.BigInteger
;
import
java.math.BigInteger
;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.HashMap
;
...
@@ -41,7 +45,7 @@ import io.jsonwebtoken.SignatureAlgorithm;
...
@@ -41,7 +45,7 @@ import io.jsonwebtoken.SignatureAlgorithm;
/**
/**
* IndexController 指向系统访问首页
* IndexController 指向系统访问首页
*
*
* @author jbolt.cn
* @author jbolt.cn
* @email 909854136@qq.com
* @email 909854136@qq.com
* @date 2018年11月4日 下午9:02:52
* @date 2018年11月4日 下午9:02:52
...
@@ -118,7 +122,7 @@ public class IndexController extends Controller {
...
@@ -118,7 +122,7 @@ public class IndexController extends Controller {
//校验密码是否符合强度设置
//校验密码是否符合强度设置
String
verify
=
password
;
String
verify
=
password
;
password
=
HashKit
.
sha256
(
password
);
password
=
HashKit
.
sha256
(
password
);
User
user
=
User
.
dao
.
template
(
"getUser"
,
username
).
findFirst
(
);
User
user
=
InfoUser
.
getUser
(
username
);
if
(
user
==
null
)
{
if
(
user
==
null
)
{
this
.
renderJson
(
Ret
.
fail
(
"msg"
,
"用户名或密码不存在: "
+
username
));
this
.
renderJson
(
Ret
.
fail
(
"msg"
,
"用户名或密码不存在: "
+
username
));
logService
.
saveAsLog
(
"login"
,
username
,
JwtInterceptor
.
getIpAddr
(
getRequest
()),
"该用户非本系统用户正在非法登录"
,
app
);
logService
.
saveAsLog
(
"login"
,
username
,
JwtInterceptor
.
getIpAddr
(
getRequest
()),
"该用户非本系统用户正在非法登录"
,
app
);
...
@@ -148,14 +152,14 @@ public class IndexController extends Controller {
...
@@ -148,14 +152,14 @@ public class IndexController extends Controller {
// 一旦开启三员 admin用户不能使用
// 一旦开启三员 admin用户不能使用
if
(
"admin"
.
equals
(
user
.
getUsername
()))
{
if
(
"admin"
.
equals
(
user
.
getUsername
()))
{
Integer
userCount
=
Db
.
queryInt
(
Db
.
getSql
(
"hasThreeMemberUsersCount"
));
Integer
userCount
=
Db
.
queryInt
(
Db
.
getSql
(
"hasThreeMemberUsersCount"
));
boolean
isExistThreeMemberUsers
=
userCount
==
null
?
false
:
(
userCount
>
0
?
true
:
false
);
boolean
isExistThreeMemberUsers
=
userCount
!=
null
&&
(
userCount
>
0
);
if
(
isExistThreeMemberUsers
)
{
if
(
isExistThreeMemberUsers
)
{
this
.
renderJson
(
Ret
.
fail
(
"msg"
,
"已开启三员管理,admin失效了。"
));
this
.
renderJson
(
Ret
.
fail
(
"msg"
,
"已开启三员管理,admin失效了。"
));
logService
.
saveAsLog
(
"login"
,
username
,
JwtInterceptor
.
getIpAddr
(
getRequest
()),
"登录失败,原因:已开启三员管理"
,
app
);
logService
.
saveAsLog
(
"login"
,
username
,
JwtInterceptor
.
getIpAddr
(
getRequest
()),
"登录失败,原因:已开启三员管理"
,
app
);
return
;
return
;
}
}
}
}
if
(
Integer
.
valueOf
(
user
.
getLocked
())
==
1
)
{
if
(
user
.
getLocked
()
!=
null
&&
Integer
.
parseInt
(
user
.
getLocked
())
==
1
)
{
this
.
renderJson
(
Ret
.
fail
(
"msg"
,
"当前账户已被锁定"
));
this
.
renderJson
(
Ret
.
fail
(
"msg"
,
"当前账户已被锁定"
));
logService
.
saveAsLog
(
"login"
,
username
,
JwtInterceptor
.
getIpAddr
(
getRequest
()),
"登录失败,原因:该用户已被锁定"
,
app
);
logService
.
saveAsLog
(
"login"
,
username
,
JwtInterceptor
.
getIpAddr
(
getRequest
()),
"登录失败,原因:该用户已被锁定"
,
app
);
return
;
return
;
...
@@ -163,19 +167,17 @@ public class IndexController extends Controller {
...
@@ -163,19 +167,17 @@ public class IndexController extends Controller {
if
(!
password
.
equals
(
user
.
getPassword
()))
{
if
(!
password
.
equals
(
user
.
getPassword
()))
{
if
(
this
.
checkErrorCount
(
user
))
{
if
(
this
.
checkErrorCount
(
user
))
{
this
.
renderJson
(
Ret
.
fail
(
"msg"
,
"您的错误次数已达5次以上,请稍后再试!"
));
this
.
renderJson
(
Ret
.
fail
(
"msg"
,
"您的错误次数已达5次以上,请稍后再试!"
));
return
;
}
else
{
}
else
{
int
errorCount
=
permitLoginTimes
-
(
user
.
getErrorcount
()
==
null
?
0
:
user
.
getErrorcount
())
-
1
;
int
errorCount
=
permitLoginTimes
-
(
user
.
getErrorcount
()
==
null
?
0
:
user
.
getErrorcount
())
-
1
;
if
(
user
.
getErrorcount
()
==
4
)
{
if
(
user
.
getErrorcount
()
!=
null
&&
user
.
getErrorcount
()
==
4
)
{
this
.
renderJson
(
Ret
.
fail
(
"msg"
,
"用户名或密码验证失败,您的账户于两小时后才可登录!"
));
this
.
renderJson
(
Ret
.
fail
(
"msg"
,
"用户名或密码验证失败,您的账户于两小时后才可登录!"
));
return
;
}
else
{
}
else
{
this
.
renderJson
(
Ret
.
fail
(
"msg"
,
"用户名或密码验证失败,您还有"
+
errorCount
+
"次机会!"
));
this
.
renderJson
(
Ret
.
fail
(
"msg"
,
"用户名或密码验证失败,您还有"
+
errorCount
+
"次机会!"
));
logService
.
saveAsLog
(
"login"
,
username
,
JwtInterceptor
.
getIpAddr
(
getRequest
()),
"登录失败,原因:密码验证错误"
,
logService
.
saveAsLog
(
"login"
,
username
,
JwtInterceptor
.
getIpAddr
(
getRequest
()),
"登录失败,原因:密码验证错误"
,
app
);
app
);
return
;
}
}
}
}
return
;
}
}
Integer
errorcount
=
user
.
getErrorcount
();
Integer
errorcount
=
user
.
getErrorcount
();
if
(
errorcount
!=
null
&&
errorcount
!=
0
)
{
if
(
errorcount
!=
null
&&
errorcount
!=
0
)
{
...
@@ -197,7 +199,7 @@ public class IndexController extends Controller {
...
@@ -197,7 +199,7 @@ public class IndexController extends Controller {
if
(!
"admin"
.
equals
(
user
.
getUsername
()))
{
if
(!
"admin"
.
equals
(
user
.
getUsername
()))
{
Integer
noLockedRolesCount
=
Db
.
queryInt
(
Db
.
getSql
(
"hasNoLockedRolesCount"
),
user
.
getUsername
());
Integer
noLockedRolesCount
=
Db
.
queryInt
(
Db
.
getSql
(
"hasNoLockedRolesCount"
),
user
.
getUsername
());
boolean
noLockedRolesFlag
=
noLockedRolesCount
==
null
?
false
:
(
noLockedRolesCount
.
intValue
()
>
0
?
true
:
false
);
boolean
noLockedRolesFlag
=
noLockedRolesCount
!=
null
&&
(
noLockedRolesCount
>
0
);
if
(!
noLockedRolesFlag
)
{
if
(!
noLockedRolesFlag
)
{
this
.
renderJson
(
Ret
.
fail
(
"msg"
,
"拥有的角色全部被锁定,不能登录系统了。"
));
this
.
renderJson
(
Ret
.
fail
(
"msg"
,
"拥有的角色全部被锁定,不能登录系统了。"
));
logService
.
saveAsLog
(
"login"
,
username
,
JwtInterceptor
.
getIpAddr
(
getRequest
()),
"登录失败,原因:该用户拥有的角色全部被锁定"
,
logService
.
saveAsLog
(
"login"
,
username
,
JwtInterceptor
.
getIpAddr
(
getRequest
()),
"登录失败,原因:该用户拥有的角色全部被锁定"
,
...
@@ -205,7 +207,7 @@ public class IndexController extends Controller {
...
@@ -205,7 +207,7 @@ public class IndexController extends Controller {
return
;
return
;
}
}
}
}
System
system
=
System
.
dao
.
template
(
"getSystemPrivatekey"
,
app
).
findFirst
(
);
System
system
=
InfoSystem
.
getSystem
(
app
);
if
(
system
==
null
)
{
if
(
system
==
null
)
{
this
.
renderJson
(
Ret
.
fail
(
"msg"
,
"没有找到应用:"
+
app
));
this
.
renderJson
(
Ret
.
fail
(
"msg"
,
"没有找到应用:"
+
app
));
logService
.
saveAsLog
(
"login"
,
username
,
JwtInterceptor
.
getIpAddr
(
getRequest
()),
"登录失败,原因:没有找到应用"
+
app
,
logService
.
saveAsLog
(
"login"
,
username
,
JwtInterceptor
.
getIpAddr
(
getRequest
()),
"登录失败,原因:没有找到应用"
+
app
,
...
@@ -273,7 +275,7 @@ public class IndexController extends Controller {
...
@@ -273,7 +275,7 @@ public class IndexController extends Controller {
while
(
userIterator
.
hasNext
())
{
while
(
userIterator
.
hasNext
())
{
nextAttr
=
userIterator
.
next
();
nextAttr
=
userIterator
.
next
();
userInfo
.
put
(
nextAttr
.
getKey
().
trim
().
toLowerCase
(),
nextAttr
.
getValue
());
userInfo
.
put
(
nextAttr
.
getKey
().
trim
().
toLowerCase
(),
nextAttr
.
getValue
());
}
}
try
{
try
{
Redis
.
use
().
hmset
(
username
+
"_INFO"
,
userInfo
);
Redis
.
use
().
hmset
(
username
+
"_INFO"
,
userInfo
);
// 设置过期时间
// 设置过期时间
...
@@ -294,6 +296,7 @@ public class IndexController extends Controller {
...
@@ -294,6 +296,7 @@ public class IndexController extends Controller {
}
}
}
}
/**
/**
* @Description: 验证密码强度
* @Description: 验证密码强度
* @authorAndDate: ChengYaqing create on 2020/10/30 10:38
* @authorAndDate: ChengYaqing create on 2020/10/30 10:38
...
@@ -365,7 +368,7 @@ public class IndexController extends Controller {
...
@@ -365,7 +368,7 @@ public class IndexController extends Controller {
/**
/**
* 通过门户系统单点登录
* 通过门户系统单点登录
*
*
* @author Guo XJ
* @author Guo XJ
* @date 2019-12-13 15:08:00
* @date 2019-12-13 15:08:00
*/
*/
...
@@ -421,7 +424,7 @@ public class IndexController extends Controller {
...
@@ -421,7 +424,7 @@ public class IndexController extends Controller {
/**
/**
* 根据邮政门户传回的code 获取用户信息
* 根据邮政门户传回的code 获取用户信息
*
*
* @Title: getUserInfoForH5
* @Title: getUserInfoForH5
* @author LDC
* @author LDC
* @date 2019-11-19 03:22:34
* @date 2019-11-19 03:22:34
...
@@ -512,10 +515,10 @@ public class IndexController extends Controller {
...
@@ -512,10 +515,10 @@ public class IndexController extends Controller {
}
}
/**
/**
* 退出系统,清空Redis 中的用户信息
* 退出系统,清空Redis 中的用户信息
* @Time:2020年7月6日 - 下午5:19:58
* @Time:2020年7月6日 - 下午5:19:58
* @author:李德才
* @author:李德才
* @param:
* @param:
* @return: void
* @return: void
* @throws
* @throws
*/
*/
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment