Skip to content

Commit

Permalink
fix: clear state on logout
Browse files Browse the repository at this point in the history
  • Loading branch information
metalurgical committed Oct 24, 2024
1 parent 34a273f commit f58e2cd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
2 changes: 2 additions & 0 deletions Sources/SingleFactorAuth/SingleFactorAuth.swift
Original file line number Diff line number Diff line change
Expand Up @@ -131,5 +131,7 @@ public class SingleFactorAuth {

public func logout() async throws {
try await sessionManager.invalidateSession()
SessionManager.deleteSessionIdFromStorage()
self.state = nil
}
}
17 changes: 9 additions & 8 deletions Tests/SingleFactorAuthTests/SapphireMainnetTests.swift
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import BigInt
import JWTKit
import XCTest
import FetchNodeDetails
import JWTKit
import SingleFactorAuth
import XCTest

final class SapphireMainnetTests: XCTestCase {
var singleFactoreAuth: SingleFactorAuth!
Expand Down Expand Up @@ -46,12 +46,13 @@ final class SapphireMainnetTests: XCTestCase {
XCTAssertEqual(requiredPrivateKey, torusKey.getPrivateKey())
XCTAssertEqual("0xA92E2C756B5b2abABc127907b02D4707dc085612", torusKey.getPublicAddress())
}

func testLogout() async throws {
let idToken = try generateIdToken(email: TORUS_TEST_EMAIL)
let loginParams = LoginParams(verifier: TEST_VERIFIER, verifierId: TORUS_TEST_EMAIL, idToken: idToken)
let _ = try await singleFactoreAuth.connect(loginParams: loginParams)
let idToken = try generateIdToken(email: TORUS_TEST_EMAIL)
let loginParams = LoginParams(verifier: TEST_VERIFIER, verifierId: TORUS_TEST_EMAIL, idToken: idToken)
let _ = try await singleFactoreAuth.connect(loginParams: loginParams)

try await singleFactoreAuth.logout()
}
try await singleFactoreAuth.logout()
XCTAssertNil(singleFactoreAuth.getSessionData())
}
}

0 comments on commit f58e2cd

Please sign in to comment.