Commit fa1c128c authored by Quxl's avatar Quxl

xxx

parent a81874b8
......@@ -2,6 +2,7 @@ package com.egolm.film.api.service;
public interface AdminTokenService extends TokenService {
final String LOGINID_COOKIE_NAME = "admin_token";
final String TOKEN_NAME = "FILM_ADMIN_LOGIN_TOKEN_NAME";
final String LOG_TYPE = "ADMIN";
......
......@@ -2,6 +2,7 @@ package com.egolm.film.api.service;
public interface MemberTokenService extends TokenService {
final String LOGINID_COOKIE_NAME = "member_token";
final String TOKEN_NAME = "FILM_MEMBER_LOGIN_TOKEN_NAME";
final String LOG_TYPE = "MEMBER";
......
......@@ -6,8 +6,6 @@ import com.egolm.film.model.LoginToken;
public interface TokenService {
final String LOGINID_COOKIE_NAME = "token";
LoginToken getToken();
LoginToken doLogin(String username, String password);
......
......@@ -2,6 +2,7 @@ package com.egolm.film.api.service;
public interface UserTokenService extends TokenService {
final String LOGINID_COOKIE_NAME = "user_token";
final String TOKEN_NAME = "FILM_USER_LOGIN_TOKEN_NAME";
final String LOG_TYPE = "USER";
......
......@@ -51,7 +51,7 @@ public class MemberTokenServiceImpl implements MemberTokenService {
Integer id = member.getId();
LoginToken token = new LoginToken(id);
session.setAttribute(TOKEN_NAME, token);
Cookie cookie = WebMvcConfig.getCookie(LOGINID_COOKIE_NAME);
Cookie cookie = WebMvcConfig.getOrCreateUUIDCookie(LOGINID_COOKIE_NAME, "/", 60*60, true);
if(cookie != null) {
memberService.updateToken(id, cookie.getValue());
}
......
......@@ -9,7 +9,6 @@ import org.springframework.stereotype.Component;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
import com.egolm.film.api.service.AdminTokenService;
import com.egolm.film.api.service.TokenService;
import com.egolm.film.config.XException;
@Component
......@@ -28,7 +27,7 @@ public class AdminLoginInterceptor extends HandlerInterceptorAdapter {
Cookie[] cookies = req.getCookies();
if(cookies != null) {
for(Cookie cookie : cookies) {
if(cookie.getName().equals(TokenService.LOGINID_COOKIE_NAME)) {
if(cookie.getName().equals(AdminTokenService.LOGINID_COOKIE_NAME)) {
sessionid = cookie.getValue();
}
}
......
......@@ -9,7 +9,6 @@ import org.springframework.stereotype.Component;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
import com.egolm.film.api.service.MemberTokenService;
import com.egolm.film.api.service.TokenService;
import com.egolm.film.config.XException;
@Component
......@@ -27,7 +26,7 @@ public class MemberLoginInterceptor extends HandlerInterceptorAdapter {
String sessionid = null;
Cookie[] cookies = req.getCookies();
for(Cookie cookie : cookies) {
if(cookie.getName().equals(TokenService.LOGINID_COOKIE_NAME)) {
if(cookie.getName().equals(MemberTokenService.LOGINID_COOKIE_NAME)) {
sessionid = cookie.getValue();
}
}
......
......@@ -8,7 +8,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
import com.egolm.film.api.service.TokenService;
import com.egolm.film.api.service.UserTokenService;
import com.egolm.film.config.XException;
......@@ -27,7 +26,7 @@ public class UserLoginInterceptor extends HandlerInterceptorAdapter {
String sessionid = null;
Cookie[] cookies = req.getCookies();
for(Cookie cookie : cookies) {
if(cookie.getName().equals(TokenService.LOGINID_COOKIE_NAME)) {
if(cookie.getName().equals(UserTokenService.LOGINID_COOKIE_NAME)) {
sessionid = cookie.getValue();
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment