Skip to content

Commit

Permalink
fixed whoami
Browse files Browse the repository at this point in the history
  • Loading branch information
emmdurin committed Dec 21, 2023
1 parent e207326 commit d5c162f
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import javax.annotation.PostConstruct;

import org.georchestra.gateway.security.GeorchestraUserMapper;
import org.georchestra.gateway.security.exceptions.DuplicatedEmailFoundException;
import org.georchestra.gateway.security.ldap.LdapConfigProperties;
import org.georchestra.security.model.GeorchestraUser;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down Expand Up @@ -87,10 +88,15 @@ void initialize() {
@GetMapping(path = "/whoami", produces = "application/json")
@ResponseBody
public Mono<Map<String, Object>> whoami(Authentication principal, ServerWebExchange exchange) {
GeorchestraUser user = Optional.ofNullable(principal).flatMap(userMapper::resolve).orElse(null);
GeorchestraUser user = null;
try {
user = Optional.ofNullable(principal).flatMap(userMapper::resolve).orElse(null);
} catch (DuplicatedEmailFoundException e) {
}

Map<String, Object> ret = new LinkedHashMap<>();
ret.put("GeorchestraUser", user);
if (principal == null) {
if ((user == null) || (principal == null)) {
ret.put("Authentication", null);
} else {
ret.put(principal.getClass().getCanonicalName(), principal);
Expand Down

0 comments on commit d5c162f

Please sign in to comment.