Skip to content

Commit

Permalink
fix: Signup from OAuth not being detected correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
sharat87 committed Nov 26, 2024
1 parent b778d2c commit d53fcdf
Showing 1 changed file with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,7 @@ public Mono<Void> onAuthenticationSuccess(
// creation) or if this was a login (existing user). What we do here to identify this, is an approximation.
// If and when we find a better way to do identify this, let's please move away from this approximation.
// If the user object was created within the last 5 seconds, we treat it as a new user.
final boolean oauthIsFromSignup =
user.getCreatedAt().isAfter(Instant.now().minusSeconds(5));
isFromSignup = user.getCreatedAt().isAfter(Instant.now().minusSeconds(5));

// Check the existing login source with the authentication source and then update the login source,
// if they are not the same.
Expand All @@ -270,26 +269,28 @@ public Mono<Void> onAuthenticationSuccess(
.subscribeOn(Schedulers.boundedElastic())
.subscribe();
}
if (oauthIsFromSignup) {
if (isFromSignup) {
final boolean isFromSignupFinal = isFromSignup;
redirectionMono = workspaceServiceHelper
.isCreateWorkspaceAllowed(TRUE)
.flatMap(isCreateWorkspaceAllowed -> {
if (isCreateWorkspaceAllowed.equals(Boolean.TRUE)) {
return createDefaultApplication(defaultWorkspaceId, authentication)
.flatMap(application -> handleOAuth2Redirect(
webFilterExchange, application, oauthIsFromSignup));
webFilterExchange, application, isFromSignupFinal));
}
return handleOAuth2Redirect(webFilterExchange, null, oauthIsFromSignup);
return handleOAuth2Redirect(webFilterExchange, null, isFromSignupFinal);
});
} else {
redirectionMono = handleOAuth2Redirect(webFilterExchange, null, oauthIsFromSignup);
redirectionMono = handleOAuth2Redirect(webFilterExchange, null, isFromSignup);
}
} else {
// form type signup/login handler
redirectionMono = formEmailVerificationRedirectionHandler(
webFilterExchange, defaultWorkspaceId, authentication, isFromSignup, createDefaultApplication);
}

final boolean isFromSignupFinal = isFromSignup;
Mono<Void> finalRedirectionMono = redirectionMono;
return sessionUserService
.getCurrentUser()
Expand All @@ -307,7 +308,7 @@ public Mono<Void> onAuthenticationSuccess(
modeOfLogin = ((OAuth2AuthenticationToken) authentication).getAuthorizedClientRegistrationId();
}

if (isFromSignup) {
if (isFromSignupFinal) {
final String inviteToken = currentUser.getInviteToken();
final boolean isFromInvite = inviteToken != null;

Expand Down

0 comments on commit d53fcdf

Please sign in to comment.