matrix-rust-sdk icon indicating copy to clipboard operation
matrix-rust-sdk copied to clipboard

SQLite store blocks login after logout

Open LunarTulip opened this issue 3 months ago • 3 comments

I just did a test in which I logged a client in with E2E encryption enabled and a SQLite store path set on the client-builder, then logged out, and then attempted to log back in.

On the second login, an error was thrown: Error: failed to read or write to the crypto store the account in the store doesn't match the account in the constructor: expected @test_account_username_redacted:matrix.org:HLLKIANREE, got @test_account_username_redacted:matrix.org:FNJIOAWFAW.

As far as I can tell, the underlying problem is that, while using a client's login-flow creates a crypto store for the session-being-logged-into, using Client::matrix_auth().logout() doesn't correspondingly delete that crypto store. Thus the store for the old session remains in place blocking the new session. (Deleting the old session's associated .sqlite3 files manually in my file system led to the subsquent next login attempt proceeding without issue.)

This seems like non-ideal behavior and I'd suggest, if not entirely having the logout method delete the SQLite store, then at least adding a settings-option to make it do so; because, as things stand, it makes for kind of an ugly workflow wherein one needs to go and manually delete the store, via std::fs or suchlike, after logging out, rather than having it auto-handled within the SDK as crypto-store-creation currently is.

LunarTulip avatar Mar 22 '24 17:03 LunarTulip