}
} else {
// Set the user in the session.
User user = userService.getCurrentUser();
String userId = user.getUserId();
Gebruiker gebruiker = gebruikerRepository
.vindGebruikerPerUserId(userId);
String identificatie;
if (gebruiker == null) {
// Make a new user.
gebruiker = new Gebruiker.Builder().id(user.getUserId())
.naam(user.getNickname()).email(user.getEmail())
.build();
identificatie = gebruikerRepository.opslaan(gebruiker);
} else {
identificatie = gebruiker.getPk();
}
synchronized (session) {
session.setAttribute(USER_KEY, identificatie);
}
return identificatie;