Skip to content

Commit f55fb7f

Browse files
Thomasrludomikula
Thomasr
authored andcommittedSep 11, 2024·
#1088 Fix issue that refresh token was lost
1 parent 2cd0b06 commit f55fb7f

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed
 

‎server/api-service/lowcoder-server/src/main/java/org/lowcoder/api/authentication/request/oauth2/request/AbstractOauth2Request.java

+1-5
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,7 @@ public Mono<AuthUser> auth(AuthRequestContext authRequestContext) {
3939

4040
public Mono<AuthUser> refresh(String refreshToken) {
4141
return refreshAuthToken(refreshToken)
42-
.flatMap(authToken -> getAuthUser(authToken).doOnNext(authUser -> {
43-
assert authUser.getAuthToken() != null;
44-
authUser.getAuthToken().setAccessToken(authToken.getAccessToken());
45-
authUser.getAuthToken().setExpireIn(authToken.getExpireIn());
46-
}))
42+
.flatMap(authToken -> getAuthUser(authToken).doOnNext(authUser -> authUser.setAuthToken(authToken)))
4743
.onErrorResume(throwable -> {
4844
log.error("failed to refresh token: ", throwable);
4945
return deferredError(FAIL_TO_GET_OIDC_INFO, "FAIL_TO_GET_OIDC_INFO", throwable.getMessage());

‎server/api-service/lowcoder-server/src/main/java/org/lowcoder/api/authentication/service/AuthenticationApiServiceImpl.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -206,16 +206,16 @@ public void updateConnection(AuthUser authUser, User user) {
206206
// clean old data
207207
oldConnection.setAuthId(authUser.getAuthContext().getAuthConfig().getId());
208208

209-
// Save the auth token which may be used in the future datasource or query.
210-
oldConnection.setAuthConnectionAuthToken(
211-
Optional.ofNullable(authUser.getAuthToken()).map(ConnectionAuthToken::of).orElse(null));
212-
oldConnection.setRawUserInfo(authUser.getRawUserInfo());
213-
214209
//if auth by google, set refresh token
215210
if (authUser.getAuthToken()!=null && oldConnection.getAuthConnectionAuthToken()!=null && StringUtils.isEmpty(authUser.getAuthToken().getRefreshToken()) && StringUtils.isNotEmpty(oldConnection.getAuthConnectionAuthToken().getRefreshToken())) {
216211
authUser.getAuthToken().setRefreshToken(oldConnection.getAuthConnectionAuthToken().getRefreshToken());
217212
}
218213

214+
// Save the auth token which may be used in the future datasource or query.
215+
oldConnection.setAuthConnectionAuthToken(
216+
Optional.ofNullable(authUser.getAuthToken()).map(ConnectionAuthToken::of).orElse(null));
217+
oldConnection.setRawUserInfo(authUser.getRawUserInfo());
218+
219219
user.setActiveAuthId(oldConnection.getAuthId());
220220
}
221221

0 commit comments

Comments
 (0)
Please sign in to comment.