Bugfix: user can change email and password accordingly
LocationBasedServices/sumoc-backend/pipeline/head This commit looks good

This commit is contained in:
2025-12-23 12:14:34 +01:00
parent 432a720370
commit 21c1319eb2
8 changed files with 230 additions and 41 deletions
@@ -48,6 +48,30 @@ public class TokenService {
return jwtEncoder.encode(JwtEncoderParameters.from(claims)).getTokenValue();
}
// Re-Authentification after change of email
public String generateUserJwt(Authentication auth, UserDTO userDTO, String email){
System.out.println(auth.getName());
Instant now = Instant.now();
List<String> roles = auth.getAuthorities().stream()
.map(authority -> authority.getAuthority().replace("ROLE_", "")) // <- WICHTIG!
.collect(Collectors.toList());
//CLAIMS define the Payload of the JWT, stores user Data etc. Payload is not encrypted, so no secret data shall be saved stored in a jwt
JwtClaimsSet claims = JwtClaimsSet.builder()
.issuer("self")
.issuedAt(now)
.subject(email)
.claim("roles",roles)
.claim("userId", userDTO.getId())
.claim("privateName", userDTO.getPrivateName())
.build();
return jwtEncoder.encode(JwtEncoderParameters.from(claims)).getTokenValue();
}
//TODO: change return type
public void decodeJwt(String jwt){
System.out.println("###############DECODED JWT##################");