autocomit

This commit is contained in:
2026-02-07 18:00:01 +01:00
parent b752e26526
commit fb630495a8
2 changed files with 13 additions and 11 deletions
+2
View File
@@ -2,6 +2,8 @@
Complete implementation of Story 0 (Walking Skeleton) with Spring Boot backend and Angular 18 frontend. Complete implementation of Story 0 (Walking Skeleton) with Spring Boot backend and Angular 18 frontend.
## 📁 Project Structure ## 📁 Project Structure
``` ```
@@ -30,28 +30,28 @@ public class JwtTokenProvider {
Date expiryDate = new Date(now.getTime() + jwtExpiration); Date expiryDate = new Date(now.getTime() + jwtExpiration);
return Jwts.builder() return Jwts.builder()
.setSubject(userDetails.getUsername()) .subject(userDetails.getUsername())
.setIssuedAt(now) .issuedAt(now)
.setExpiration(expiryDate) .expiration(expiryDate)
.signWith(getSigningKey(), SignatureAlgorithm.HS512) .signWith(getSigningKey())
.compact(); .compact();
} }
public String getUsernameFromToken(String token) { public String getUsernameFromToken(String token) {
Claims claims = Jwts.parserBuilder() Claims claims = Jwts.parser()
.setSigningKey(getSigningKey()) .verifyWith(getSigningKey())
.build() .build()
.parseClaimsJws(token) .parseSignedClaims(token)
.getBody(); .getPayload();
return claims.getSubject(); return claims.getSubject();
} }
public boolean validateToken(String token) { public boolean validateToken(String token) {
try { try {
Jwts.parserBuilder() Jwts.parser()
.setSigningKey(getSigningKey()) .verifyWith(getSigningKey())
.build() .build()
.parseClaimsJws(token); .parseSignedClaims(token);
return true; return true;
} catch (JwtException | IllegalArgumentException ex) { } catch (JwtException | IllegalArgumentException ex) {
return false; return false;