Skip to content

Commit f4e23ad

Browse files
committed
Fix authentication failure
1 parent e4f4648 commit f4e23ad

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* Case order by format from lower hyphen to upper underscore
88
* Fix mybatis flex order query error
99
* Fix `Spring Boot Admin` 401 error
10+
* Fix authentication failure
1011

1112
### Optimization
1213

tang-framework/src/main/kotlin/com/tang/framework/utils/AuthenticationUtils.kt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.tang.framework.utils
22

33
import org.springframework.security.authentication.AbstractAuthenticationToken
4+
import org.springframework.security.core.GrantedAuthority
45

56
import com.tang.commons.enumeration.LoginType
67
import com.tang.framework.security.authentication.email.EmailAuthenticationToken
@@ -13,11 +14,11 @@ import com.tang.framework.security.authentication.username.UsernameAuthenticatio
1314
object AuthenticationUtils {
1415

1516
@JvmStatic
16-
fun newInstance(loginType: String, vararg params: Any): AbstractAuthenticationToken {
17+
fun newInstance(loginType: String, principal: Any, authorities: Collection<GrantedAuthority>): AbstractAuthenticationToken {
1718
return when (LoginType.getLoginType(loginType)) {
18-
LoginType.USERNAME -> UsernameAuthenticationToken(params[0], params[1])
19-
LoginType.EMAIL -> EmailAuthenticationToken(params[0], params[1])
20-
LoginType.GITHUB -> GitHubAuthenticationToken(params[0])
19+
LoginType.USERNAME -> UsernameAuthenticationToken(principal, authorities)
20+
LoginType.EMAIL -> EmailAuthenticationToken(principal, authorities)
21+
LoginType.GITHUB -> GitHubAuthenticationToken(principal)
2122
else -> throw IllegalArgumentException("Unexpected login type: $loginType")
2223
}
2324
}

0 commit comments

Comments
 (0)