Skip to content

Commit dccf2e9

Browse files
committed
Let a session decide if is valid or not
1 parent d373329 commit dccf2e9

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

ios-base/Common/Models/Session.swift

+2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ struct Session: Codable {
1414
var accessToken: String?
1515
var expiry: Date?
1616

17+
var isValid: Bool { [uid, accessToken, client].allSatisfy { $0 != nil } }
18+
1719
private enum CodingKeys: String, CodingKey {
1820
case uid
1921
case client

ios-base/Managers/SessionManager.swift

+1-5
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,6 @@ class SessionManager: NSObject {
3232
}
3333

3434
static var validSession: Bool {
35-
if let session = currentSession, let uid = session.uid,
36-
let tkn = session.accessToken, let client = session.client {
37-
return !uid.isEmpty && !tkn.isEmpty && !client.isEmpty
38-
}
39-
return false
35+
currentSession?.isValid ?? false
4036
}
4137
}

0 commit comments

Comments
 (0)