Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
member-api
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
曲欣亮
member-api
Commits
a81874b8
Commit
a81874b8
authored
Nov 23, 2018
by
Quxl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
xx
parent
9c3e3a80
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
28 additions
and
7 deletions
+28
-7
TokenService.java
src/main/java/com/egolm/film/api/service/TokenService.java
+1
-1
AdminTokenServiceImpl.java
...om/egolm/film/api/service/impl/AdminTokenServiceImpl.java
+1
-1
MemberTokenServiceImpl.java
...m/egolm/film/api/service/impl/MemberTokenServiceImpl.java
+1
-1
UserTokenServiceImpl.java
...com/egolm/film/api/service/impl/UserTokenServiceImpl.java
+1
-1
WebMvcConfig.java
src/main/java/com/egolm/film/config/WebMvcConfig.java
+21
-0
AdminLoginInterceptor.java
.../egolm/film/config/interceptor/AdminLoginInterceptor.java
+1
-1
MemberLoginInterceptor.java
...egolm/film/config/interceptor/MemberLoginInterceptor.java
+1
-1
UserLoginInterceptor.java
...m/egolm/film/config/interceptor/UserLoginInterceptor.java
+1
-1
No files found.
src/main/java/com/egolm/film/api/service/TokenService.java
View file @
a81874b8
...
@@ -6,7 +6,7 @@ import com.egolm.film.model.LoginToken;
...
@@ -6,7 +6,7 @@ import com.egolm.film.model.LoginToken;
public
interface
TokenService
{
public
interface
TokenService
{
final
String
JSESSIONID
=
"JSESSIONID
"
;
final
String
LOGINID_COOKIE_NAME
=
"token
"
;
LoginToken
getToken
();
LoginToken
getToken
();
...
...
src/main/java/com/egolm/film/api/service/impl/AdminTokenServiceImpl.java
View file @
a81874b8
...
@@ -43,7 +43,7 @@ public class AdminTokenServiceImpl implements AdminTokenService {
...
@@ -43,7 +43,7 @@ public class AdminTokenServiceImpl implements AdminTokenService {
Integer
adminid
=
admin
.
getAdminid
();
Integer
adminid
=
admin
.
getAdminid
();
LoginToken
token
=
new
LoginToken
(
adminid
);
LoginToken
token
=
new
LoginToken
(
adminid
);
session
.
setAttribute
(
TOKEN_NAME
,
token
);
session
.
setAttribute
(
TOKEN_NAME
,
token
);
Cookie
cookie
=
WebMvcConfig
.
get
Cookie
(
JSESSIONID
);
Cookie
cookie
=
WebMvcConfig
.
get
OrCreateUUIDCookie
(
LOGINID_COOKIE_NAME
,
"/"
,
60
*
60
,
true
);
if
(
cookie
!=
null
)
{
if
(
cookie
!=
null
)
{
String
sql
=
"update fc_admin set token = ? where adminid = ?"
;
String
sql
=
"update fc_admin set token = ? where adminid = ?"
;
jdbcTemplate
.
executeUpdate
(
sql
,
cookie
.
getValue
(),
adminid
);
jdbcTemplate
.
executeUpdate
(
sql
,
cookie
.
getValue
(),
adminid
);
...
...
src/main/java/com/egolm/film/api/service/impl/MemberTokenServiceImpl.java
View file @
a81874b8
...
@@ -51,7 +51,7 @@ public class MemberTokenServiceImpl implements MemberTokenService {
...
@@ -51,7 +51,7 @@ public class MemberTokenServiceImpl implements MemberTokenService {
Integer
id
=
member
.
getId
();
Integer
id
=
member
.
getId
();
LoginToken
token
=
new
LoginToken
(
id
);
LoginToken
token
=
new
LoginToken
(
id
);
session
.
setAttribute
(
TOKEN_NAME
,
token
);
session
.
setAttribute
(
TOKEN_NAME
,
token
);
Cookie
cookie
=
WebMvcConfig
.
getCookie
(
JSESSIONID
);
Cookie
cookie
=
WebMvcConfig
.
getCookie
(
LOGINID_COOKIE_NAME
);
if
(
cookie
!=
null
)
{
if
(
cookie
!=
null
)
{
memberService
.
updateToken
(
id
,
cookie
.
getValue
());
memberService
.
updateToken
(
id
,
cookie
.
getValue
());
}
}
...
...
src/main/java/com/egolm/film/api/service/impl/UserTokenServiceImpl.java
View file @
a81874b8
...
@@ -47,7 +47,7 @@ public class UserTokenServiceImpl implements UserTokenService {
...
@@ -47,7 +47,7 @@ public class UserTokenServiceImpl implements UserTokenService {
Long
uid
=
user
.
getUid
();
Long
uid
=
user
.
getUid
();
LoginToken
token
=
new
LoginToken
(
uid
);
LoginToken
token
=
new
LoginToken
(
uid
);
session
.
setAttribute
(
TOKEN_NAME
,
token
);
session
.
setAttribute
(
TOKEN_NAME
,
token
);
Cookie
cookie
=
WebMvcConfig
.
getCookie
(
JSESSIONID
);
Cookie
cookie
=
WebMvcConfig
.
getCookie
(
LOGINID_COOKIE_NAME
);
if
(
cookie
!=
null
)
{
if
(
cookie
!=
null
)
{
jdbcTemplate
.
executeUpdate
(
"update fc_user set token = ? where uid = ?"
,
cookie
.
getValue
(),
uid
);
jdbcTemplate
.
executeUpdate
(
"update fc_user set token = ? where uid = ?"
,
cookie
.
getValue
(),
uid
);
}
}
...
...
src/main/java/com/egolm/film/config/WebMvcConfig.java
View file @
a81874b8
...
@@ -18,6 +18,7 @@ import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
...
@@ -18,6 +18,7 @@ import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import
org.springframework.web.servlet.config.annotation.PathMatchConfigurer
;
import
org.springframework.web.servlet.config.annotation.PathMatchConfigurer
;
import
org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
;
import
org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
;
import
com.egolm.common.StringUtil
;
import
com.egolm.film.config.interceptor.AdminLoginInterceptor
;
import
com.egolm.film.config.interceptor.AdminLoginInterceptor
;
import
com.egolm.film.config.interceptor.LocaleInterceptor
;
import
com.egolm.film.config.interceptor.LocaleInterceptor
;
import
com.egolm.film.config.interceptor.MemberLoginInterceptor
;
import
com.egolm.film.config.interceptor.MemberLoginInterceptor
;
...
@@ -98,6 +99,26 @@ public class WebMvcConfig extends WebMvcConfigurerAdapter {
...
@@ -98,6 +99,26 @@ public class WebMvcConfig extends WebMvcConfigurerAdapter {
return
null
;
return
null
;
}
}
public
static
Cookie
getOrCreateUUIDCookie
(
String
name
,
String
path
,
int
expiry
,
boolean
httpOnly
)
{
HttpServletRequest
request
=
WebMvcConfig
.
getRequest
();
if
(
request
!=
null
)
{
Cookie
[]
cookies
=
request
.
getCookies
();
if
(
cookies
!=
null
)
{
for
(
Cookie
cookie
:
cookies
)
{
if
(
cookie
.
getName
().
equals
(
name
))
{
return
cookie
;
}
}
}
}
Cookie
cookie
=
new
Cookie
(
name
,
StringUtil
.
getUid
().
toLowerCase
());
cookie
.
setPath
(
path
);
cookie
.
setHttpOnly
(
httpOnly
);
cookie
.
setMaxAge
(
expiry
);
getResponse
().
addCookie
(
cookie
);
return
cookie
;
}
public
static
String
getRemoteIp
()
{
public
static
String
getRemoteIp
()
{
HttpServletRequest
request
=
WebMvcConfig
.
getRequest
();
HttpServletRequest
request
=
WebMvcConfig
.
getRequest
();
String
ip
=
request
.
getHeader
(
"X-Real_IP"
);
String
ip
=
request
.
getHeader
(
"X-Real_IP"
);
...
...
src/main/java/com/egolm/film/config/interceptor/AdminLoginInterceptor.java
View file @
a81874b8
...
@@ -28,7 +28,7 @@ public class AdminLoginInterceptor extends HandlerInterceptorAdapter {
...
@@ -28,7 +28,7 @@ public class AdminLoginInterceptor extends HandlerInterceptorAdapter {
Cookie
[]
cookies
=
req
.
getCookies
();
Cookie
[]
cookies
=
req
.
getCookies
();
if
(
cookies
!=
null
)
{
if
(
cookies
!=
null
)
{
for
(
Cookie
cookie
:
cookies
)
{
for
(
Cookie
cookie
:
cookies
)
{
if
(
cookie
.
getName
().
equals
(
TokenService
.
JSESSIONID
))
{
if
(
cookie
.
getName
().
equals
(
TokenService
.
LOGINID_COOKIE_NAME
))
{
sessionid
=
cookie
.
getValue
();
sessionid
=
cookie
.
getValue
();
}
}
}
}
...
...
src/main/java/com/egolm/film/config/interceptor/MemberLoginInterceptor.java
View file @
a81874b8
...
@@ -27,7 +27,7 @@ public class MemberLoginInterceptor extends HandlerInterceptorAdapter {
...
@@ -27,7 +27,7 @@ public class MemberLoginInterceptor extends HandlerInterceptorAdapter {
String
sessionid
=
null
;
String
sessionid
=
null
;
Cookie
[]
cookies
=
req
.
getCookies
();
Cookie
[]
cookies
=
req
.
getCookies
();
for
(
Cookie
cookie
:
cookies
)
{
for
(
Cookie
cookie
:
cookies
)
{
if
(
cookie
.
getName
().
equals
(
TokenService
.
JSESSIONID
))
{
if
(
cookie
.
getName
().
equals
(
TokenService
.
LOGINID_COOKIE_NAME
))
{
sessionid
=
cookie
.
getValue
();
sessionid
=
cookie
.
getValue
();
}
}
}
}
...
...
src/main/java/com/egolm/film/config/interceptor/UserLoginInterceptor.java
View file @
a81874b8
...
@@ -27,7 +27,7 @@ public class UserLoginInterceptor extends HandlerInterceptorAdapter {
...
@@ -27,7 +27,7 @@ public class UserLoginInterceptor extends HandlerInterceptorAdapter {
String
sessionid
=
null
;
String
sessionid
=
null
;
Cookie
[]
cookies
=
req
.
getCookies
();
Cookie
[]
cookies
=
req
.
getCookies
();
for
(
Cookie
cookie
:
cookies
)
{
for
(
Cookie
cookie
:
cookies
)
{
if
(
cookie
.
getName
().
equals
(
TokenService
.
JSESSIONID
))
{
if
(
cookie
.
getName
().
equals
(
TokenService
.
LOGINID_COOKIE_NAME
))
{
sessionid
=
cookie
.
getValue
();
sessionid
=
cookie
.
getValue
();
}
}
}
}
...
...
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