diff --git a/src/main/java/org/ntlab/acanthus_server/entities/Account.java b/src/main/java/org/ntlab/acanthus_server/entities/Account.java index 1c6cb4e..f35e8b7 100644 --- a/src/main/java/org/ntlab/acanthus_server/entities/Account.java +++ b/src/main/java/org/ntlab/acanthus_server/entities/Account.java @@ -26,6 +26,10 @@ import com.fasterxml.jackson.annotation.JsonPropertyOrder; import org.ntlab.acanthus_server.models.Gallery; +import java.time.Duration; +import java.time.LocalDateTime; +import java.util.Calendar; +import java.util.Date; import java.util.HashMap; import java.util.UUID; @@ -54,6 +58,9 @@ private String password; @JsonIgnore private boolean isDummy; + @JsonIgnore + private LocalDateTime lastAccess; + //----------------------------------------------------------------- //コンストラクト @@ -115,6 +122,18 @@ return (this.token); } + public boolean isCollectToken(String token){ + int timeoutThreshold = 1; + + var nowDateTime = LocalDateTime.now(); + if(lastAccess==null) lastAccess = nowDateTime; + + var duration = Duration.between(nowDateTime,lastAccess); + if(duration.toHours()>timeoutThreshold) return false; + + return token.equals(this.token); + } + public HashMap getWorkHashMap() { return this.workHashMap; } @@ -170,6 +189,7 @@ this.email = "d@dummy.com"; this.password = "nittalab"; this.token = "abc"; + this.lastAccess = LocalDateTime.of(2019, 12, 31, 0, 0, 0); } //----------------------------------------------------------------- }