fix token 获取 bug
This commit is contained in:
@@ -17,7 +17,7 @@ buildscript {
|
|||||||
|
|
||||||
subprojects {
|
subprojects {
|
||||||
group 'com.synebula'
|
group 'com.synebula'
|
||||||
version '1.5.0'
|
version '1.5.1'
|
||||||
|
|
||||||
buildscript {
|
buildscript {
|
||||||
repositories {
|
repositories {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.synebula.gaea.app
|
package com.synebula.gaea.app
|
||||||
|
|
||||||
import com.google.gson.Gson
|
import com.synebula.gaea.app.component.security.session.UserSession
|
||||||
import com.synebula.gaea.data.message.HttpMessage
|
import com.synebula.gaea.data.message.HttpMessage
|
||||||
import com.synebula.gaea.data.message.HttpMessageFactory
|
import com.synebula.gaea.data.message.HttpMessageFactory
|
||||||
import com.synebula.gaea.data.message.Status
|
import com.synebula.gaea.data.message.Status
|
||||||
@@ -58,14 +58,12 @@ interface IApplication {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取用户信息
|
* 获取用户信息
|
||||||
* @param clazz 用户信息结构类
|
|
||||||
*/
|
*/
|
||||||
fun <T> userSession(clazz: Class<T>): T? {
|
fun userSession(): UserSession? {
|
||||||
try {
|
try {
|
||||||
val authentication = SecurityContextHolder.getContext().authentication.principal.toString()
|
val authentication = SecurityContextHolder.getContext().authentication.principal
|
||||||
try {
|
try {
|
||||||
val gson = Gson()
|
return authentication as UserSession
|
||||||
return gson.fromJson(authentication, clazz)
|
|
||||||
} catch (ex: Exception) {
|
} catch (ex: Exception) {
|
||||||
logger.error(this, ex, "[$name]解析用户信息异常!用户信息:$authentication: ${ex.message}")
|
logger.error(this, ex, "[$name]解析用户信息异常!用户信息:$authentication: ${ex.message}")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user