File tree 1 file changed +6
-5
lines changed
server/src/main/java/run/ikaros/server/core/tag
1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change 5
5
import static org .springdoc .core .fn .builders .requestbody .Builder .requestBodyBuilder ;
6
6
7
7
import io .swagger .v3 .oas .annotations .enums .ParameterIn ;
8
+ import java .security .Principal ;
8
9
import java .util .Optional ;
9
10
import lombok .extern .slf4j .Slf4j ;
10
11
import org .springdoc .webflux .core .fn .SpringdocRouteBuilder ;
11
- import org .springframework .security .authentication .AuthenticationCredentialsNotFoundException ;
12
12
import org .springframework .stereotype .Component ;
13
13
import org .springframework .util .Assert ;
14
14
import org .springframework .web .reactive .function .server .RouterFunction ;
@@ -151,10 +151,11 @@ private Mono<ServerResponse> listAttachmentTagsByAttachmentId(ServerRequest requ
151
151
152
152
private Mono <ServerResponse > create (ServerRequest request ) {
153
153
return request .bodyToMono (Tag .class )
154
- .flatMap (tag -> userService .getUserIdFromSecurityContext ()
155
- .map (tag ::setUserId )
156
- .onErrorResume (AuthenticationCredentialsNotFoundException .class ,
157
- e -> Mono .just (tag )))
154
+ .flatMap (tag -> request .principal ()
155
+ .map (Principal ::getName )
156
+ .flatMap (userService ::getUserByUsername )
157
+ .map (user -> user .entity ().getId ())
158
+ .map (tag ::setUserId ))
158
159
.flatMap (tagService ::create )
159
160
.flatMap (tag -> ServerResponse .ok ().bodyValue (tag ));
160
161
}
You can’t perform that action at this time.
0 commit comments