Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
R
restful
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
李永强
restful
Commits
8f8a5050
Commit
8f8a5050
authored
Oct 24, 2019
by
李永强
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复bug
parent
114b1240
Pipeline
#214
canceled with stages
Changes
3
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
19 deletions
+11
-19
LoginIntercept.java
...ain/java/com/restful/common/intercept/LoginIntercept.java
+2
-2
PasswordUtils.java
src/main/java/com/restful/utils/PasswordUtils.java
+7
-8
user.xml
src/main/resources/mapper/user.xml
+2
-9
No files found.
src/main/java/com/restful/common/intercept/LoginIntercept.java
View file @
8f8a5050
...
@@ -65,12 +65,12 @@ public class LoginIntercept implements HandlerInterceptor {
...
@@ -65,12 +65,12 @@ public class LoginIntercept implements HandlerInterceptor {
returnJson
(
response
,
result
);
returnJson
(
response
,
result
);
return
false
;
return
false
;
}
}
if
(
user
.
getStopUse
())
{
if
(
user
.
getStopUse
()
!=
null
&&
user
.
getStopUse
()
)
{
ApiResult
result
=
new
ApiResult
(
Constants
.
INVALID_USER
);
ApiResult
result
=
new
ApiResult
(
Constants
.
INVALID_USER
);
returnJson
(
response
,
result
);
returnJson
(
response
,
result
);
return
false
;
return
false
;
}
}
if
(
user
.
getResetPassword
())
{
if
(
user
.
getResetPassword
()
!=
null
&&
user
.
getResetPassword
()
)
{
ApiResult
result
=
new
ApiResult
(
Constants
.
FAIL
,
"第一次登录请修改密码"
);
ApiResult
result
=
new
ApiResult
(
Constants
.
FAIL
,
"第一次登录请修改密码"
);
returnJson
(
response
,
result
);
returnJson
(
response
,
result
);
return
false
;
return
false
;
...
...
src/main/java/com/restful/utils/PasswordUtils.java
View file @
8f8a5050
...
@@ -3,6 +3,7 @@ package com.restful.utils;
...
@@ -3,6 +3,7 @@ package com.restful.utils;
import
com.restful.common.Constants
;
import
com.restful.common.Constants
;
import
com.restful.common.entity.ServiceException
;
import
com.restful.common.entity.ServiceException
;
import
com.restful.domain.User
;
import
com.restful.domain.User
;
import
org.apache.commons.codec.digest.DigestUtils
;
public
class
PasswordUtils
{
public
class
PasswordUtils
{
...
@@ -10,7 +11,7 @@ public class PasswordUtils {
...
@@ -10,7 +11,7 @@ public class PasswordUtils {
private
static
final
String
publicSalt
=
"a_simple_salt"
;
private
static
final
String
publicSalt
=
"a_simple_salt"
;
public
static
void
login
(
CacheUtils
cacheUtils
,
User
user
,
String
password
)
throws
ServiceException
{
public
static
void
login
(
CacheUtils
cacheUtils
,
User
user
,
String
password
)
throws
ServiceException
{
if
(
user
.
getStopUse
())
if
(
user
.
getStopUse
()
!=
null
&&
user
.
getStopUse
()
)
throw
new
ServiceException
(
Constants
.
INVALID_USER
);
throw
new
ServiceException
(
Constants
.
INVALID_USER
);
Integer
integer
=
cacheUtils
.
getRetryCount
(
user
.
getId
());
Integer
integer
=
cacheUtils
.
getRetryCount
(
user
.
getId
());
if
(
integer
!=
null
&&
integer
>=
5
)
{
if
(
integer
!=
null
&&
integer
>=
5
)
{
...
@@ -23,20 +24,18 @@ public class PasswordUtils {
...
@@ -23,20 +24,18 @@ public class PasswordUtils {
cacheUtils
.
delRetryCount
(
user
.
getId
());
cacheUtils
.
delRetryCount
(
user
.
getId
());
}
}
p
ublic
static
boolean
matching
(
String
realPassword
,
String
password
)
{
p
rivate
static
boolean
matching
(
String
realPassword
,
String
password
)
{
/*
String salt = DigestUtils.md5Hex(password + publicSalt);
String
salt
=
DigestUtils
.
md5Hex
(
password
+
publicSalt
);
password
=
DigestUtils
.
md5Hex
(
password
+
salt
);
password
=
DigestUtils
.
md5Hex
(
password
+
salt
);
if
(
realPassword
.
equals
(
password
))
{
if
(
realPassword
.
equals
(
password
))
{
return
true
;
return
true
;
}
}
return false;*/
return
false
;
return
realPassword
.
equals
(
password
);
}
}
public
static
String
encryption
(
String
password
)
{
public
static
String
encryption
(
String
password
)
{
/*String salt = DigestUtils.md5Hex(password + publicSalt);
String
salt
=
DigestUtils
.
md5Hex
(
password
+
publicSalt
);
return DigestUtils.md5Hex(password + salt);*/
return
DigestUtils
.
md5Hex
(
password
+
salt
);
return
password
;
}
}
}
}
src/main/resources/mapper/user.xml
View file @
8f8a5050
...
@@ -20,9 +20,8 @@
...
@@ -20,9 +20,8 @@
</resultMap>
</resultMap>
<insert
id=
"addUser"
useGeneratedKeys=
"true"
keyProperty=
"id"
>
<insert
id=
"addUser"
useGeneratedKeys=
"true"
keyProperty=
"id"
>
insert into users (user_username, user_password, user_name, user_create_time, user_update_time, user_phone,
insert into users (user_username, user_password, user_name, user_create_time, user_update_time, user_phone)
user_company)
values (#{userName}, #{password}, #{name}, #{createTime}, #{updateTime}, #{phone})
values (#{userName}, #{password}, #{name}, #{createTime}, #{updateTime}, #{phone}, #{company.id})
</insert>
</insert>
<select
id=
"getUserById"
resultMap=
"userMap_ex"
>
<select
id=
"getUserById"
resultMap=
"userMap_ex"
>
...
@@ -47,9 +46,6 @@
...
@@ -47,9 +46,6 @@
left join user_role on ur_user_id = user_id
left join user_role on ur_user_id = user_id
left join role on role_id = ur_role_id
left join role on role_id = ur_role_id
where role_id = '${@com.jianju.detecting.field.RoleTable@detection_admin.id}'
where role_id = '${@com.jianju.detecting.field.RoleTable@detection_admin.id}'
<if
test=
"companyId!=null"
>
and user_company = #{companyId}
</if>
<if
test=
"name!=null"
>
<if
test=
"name!=null"
>
and user_name like '%'||#{name}||'%'
and user_name like '%'||#{name}||'%'
</if>
</if>
...
@@ -70,9 +66,6 @@
...
@@ -70,9 +66,6 @@
<if
test=
"roleId!=null"
>
<if
test=
"roleId!=null"
>
and ur_role_id = #{roleId}
and ur_role_id = #{roleId}
</if>
</if>
<if
test=
"companyId!=null"
>
and user_company = #{companyId}
</if>
<if
test=
"username != null"
>
<if
test=
"username != null"
>
and user_username = #{username}
and user_username = #{username}
</if>
</if>
...
...
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