add connected_at

This commit is contained in:
Valentin CZERYBA 2022-08-07 17:38:36 +02:00
parent 3a70c5e767
commit a555239514
2 changed files with 5 additions and 0 deletions

View File

@ -49,6 +49,8 @@ public class UsersEntity extends PanacheEntityBase {
public LocalDateTime updated_at;
@ColumnDefault("null")
public LocalDateTime deleted_at;
@ColumnDefault("null")
public LocalDateTime connected_at;
public static UsersEntity findByPseudo(String pseudo){
return find("pseudo", pseudo).firstResult();

View File

@ -2,6 +2,7 @@ package com.covas.Resources;
import java.nio.charset.StandardCharsets;
import java.time.Duration;
import java.time.LocalDateTime;
import javax.inject.Inject;
import javax.ws.rs.CookieParam;
@ -71,6 +72,8 @@ public class TokenRessource {
// or create a JWT token encrypted using the 'A256KW' algorithm
// Jwt.upn("alice").encryptWithSecret(secret);
String nameEncoded = Base64.toBase64String(name.getBytes(StandardCharsets.UTF_8));
users.connected_at = LocalDateTime.now();
users.persist();
return Response.status(Response.Status.CREATED).cookie(new NewCookie(new Cookie("jwt", newJwtCookie), "Token JWT", expires, false), new NewCookie(new Cookie("user", nameEncoded), "Username", expires, false)).build();
}
// All mp.jwt and smallrye.jwt properties are still effective, only the verification key is customized.