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 f35e8b7..0f911e4 100644 --- a/src/main/java/org/ntlab/acanthus_server/entities/Account.java +++ b/src/main/java/org/ntlab/acanthus_server/entities/Account.java @@ -24,8 +24,11 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import jdk.jshell.execution.LoaderDelegate; import org.ntlab.acanthus_server.models.Gallery; +import javax.xml.crypto.Data; +import java.text.DateFormat; import java.time.Duration; import java.time.LocalDateTime; import java.util.Calendar; @@ -70,6 +73,7 @@ //----------------------------------------------------------------- public Account(Integer uid, String name, String email, String password) { + this.isDummy = false; this.uid = uid; this.name = name; this.email = email; @@ -122,17 +126,6 @@ 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; @@ -168,7 +161,7 @@ //----------------------------------------------------------------- //----------------------------------------------------------------- - // トークンを更新する 藤井 + // トークンを更新する public void updateToken() { if (!isDummy) this.token = UUID.randomUUID().toString(); } @@ -178,7 +171,20 @@ public boolean isMatchedPassword(String password) { return this.password.equals(password); } + //----------------------------------------------------------------- + // トークンのチェック + public boolean isCollectToken(String token){ + var timeoutThreshold = 3; + var nowDateTime = LocalDateTime.now(); + if(lastAccess==null) lastAccess = nowDateTime; + + // 時刻比較 + var duration = Duration.between(lastAccess, nowDateTime).toHours(); + if(duration > timeoutThreshold) return false; + + return token.equals(this.token); + } //----------------------------------------------------------------- //----------------------------------------------------------------- // ダミー @@ -189,7 +195,9 @@ this.email = "d@dummy.com"; this.password = "nittalab"; this.token = "abc"; - this.lastAccess = LocalDateTime.of(2019, 12, 31, 0, 0, 0); + this.lastAccess = LocalDateTime.now(); + + //this.lastAccess = LocalDateTime.of(2015, 12, 15, 0, 0); } //----------------------------------------------------------------- }