Bugfix: user can change email and password accordingly
LocationBasedServices/sumoc-backend/pipeline/head This commit looks good
LocationBasedServices/sumoc-backend/pipeline/head This commit looks good
This commit is contained in:
@@ -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##################");
|
||||
|
||||
Reference in New Issue
Block a user