Skip to content

Commit 513f1e7

Browse files
author
Aidan Laing
committed
Null Token Expiry
Now returns expired if expired is null
1 parent 8047af0 commit 513f1e7

File tree

1 file changed

+10
-4
lines changed
  • mobileauthentication/src/main/java/ca/bc/gov/mobileauthentication/data/models

1 file changed

+10
-4
lines changed

mobileauthentication/src/main/java/ca/bc/gov/mobileauthentication/data/models/Token.kt

+10-4
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,18 @@ data class Token(
1515
@SerializedName("id_token") val idToken: String?,
1616
@SerializedName("not-before-policy") val notBeforePolicy: Long?,
1717
@SerializedName("session_state") val sessionState: String?,
18-
@SerializedName("expires_at") val expiresAt: Long = System.currentTimeMillis() + ((expiresIn ?: 0) * 1000),
19-
@SerializedName("refresh_expires_at") val refreshExpiresAt: Long = System.currentTimeMillis() + ((refreshExpiresIn ?: 0) * 1000)
18+
@SerializedName("expires_at") val expiresAt: Long? = System.currentTimeMillis() + ((expiresIn ?: 0) * 1000),
19+
@SerializedName("refresh_expires_at") val refreshExpiresAt: Long? = System.currentTimeMillis() + ((refreshExpiresIn ?: 0) * 1000)
2020
) {
2121

22-
fun isExpired(currentTime: Long = System.currentTimeMillis()): Boolean = expiresAt > currentTime
22+
fun isExpired(currentTime: Long = System.currentTimeMillis()): Boolean {
23+
if (expiresAt == null) return true
24+
return expiresAt > currentTime
25+
}
2326

24-
fun isRefreshExpired(currentTime: Long = System.currentTimeMillis()): Boolean = refreshExpiresAt > currentTime
27+
fun isRefreshExpired(currentTime: Long = System.currentTimeMillis()): Boolean {
28+
if (refreshExpiresAt == null) return true
29+
return refreshExpiresAt > currentTime
30+
}
2531

2632
}

0 commit comments

Comments
 (0)