use of com.blade.mvc.http.wrapper.Session in project tale by otale.
the class TaleUtils method getLoginUser.
/**
* 返回当前登录用户
*
* @return
*/
public static Users getLoginUser() {
Session session = WebContextHolder.session();
if (null == session) {
return null;
}
Users user = session.attribute(TaleConst.LOGIN_SESSION_KEY);
return user;
}
use of com.blade.mvc.http.wrapper.Session in project blade by biezhi.
the class CSRFTokenManager method createNewToken.
/**
* Create a token
*
* @param request request object
* @param response response object
* @return return token
*/
public static String createNewToken(Request request, Response response) {
String token = null;
synchronized (request) {
Session session = request.session();
session.removeAttribute(config.session);
token = HASHID.encode(System.currentTimeMillis());
session.attribute(config.session, token);
if (config.setHeader) {
response.header(config.header, token);
}
if (config.setCookie) {
response.cookie(config.cookiePath, config.cookie, token, config.expire, config.secured);
}
LOGGER.debug("create csrf_token:{}", token);
}
return token;
}
use of com.blade.mvc.http.wrapper.Session in project blade by biezhi.
the class CSRFTokenManager method createToken.
/**
* Create a token
*
* @param request request object
* @param response response object
* @return return token
*/
public static String createToken(Request request, Response response) {
String token = null;
synchronized (request) {
Session session = request.session();
String objToken = session.attribute(config.session);
if (StringKit.isBlank(objToken)) {
token = createNewToken(request, response);
LOGGER.debug("create csrf_token:{}", token);
} else {
token = objToken;
session.attribute(config.session, token);
}
}
return token;
}