Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
import org.springframework.util.StringUtils;
import org.springframework.web.server.ServerWebExchange;
import org.springframework.web.server.WebFilterChain;
import org.springframework.web.server.WebSession;
import reactor.core.publisher.Mono;
import reactor.core.scheduler.Schedulers;

Expand Down Expand Up @@ -159,18 +158,16 @@ public Mono<User> signupAndLogin(User user, ServerWebExchange exchange) {
});
});

return Mono.zip(createUserMono, exchange.getSession(), ReactiveSecurityContextHolder.getContext())
return Mono.zip(createUserMono, ReactiveSecurityContextHolder.getContext())
.switchIfEmpty(Mono.error(new AppsmithException(AppsmithError.INTERNAL_SERVER_ERROR)))
.flatMap(tuple -> {
final User savedUser = tuple.getT1().getUser();
final String workspaceId = tuple.getT1().getDefaultWorkspaceId();
final WebSession session = tuple.getT2();
final SecurityContext securityContext = tuple.getT3();
final SecurityContext securityContext = tuple.getT2();

Authentication authentication =
new UsernamePasswordAuthenticationToken(savedUser, null, savedUser.getAuthorities());
securityContext.setAuthentication(authentication);
session.getAttributes().put(DEFAULT_SPRING_SECURITY_CONTEXT_ATTR_NAME, securityContext);

final WebFilterExchange webFilterExchange = new WebFilterExchange(exchange, EMPTY_WEB_FILTER_CHAIN);

Expand All @@ -190,7 +187,13 @@ public Mono<User> signupAndLogin(User user, ServerWebExchange exchange) {
Mono<Integer> authenticationSuccessMono = authenticationSuccessHandler
.onAuthenticationSuccess(
webFilterExchange, authentication, createApplication, true, workspaceId)
.thenReturn(1)
.then(exchange.getSession())
.map(webSession -> {
webSession
.getAttributes()
.put(DEFAULT_SPRING_SECURITY_CONTEXT_ATTR_NAME, securityContext);
return 1;
})
.elapsed()
.flatMap(pair -> {
log.debug(
Expand Down