matrix-org / matrix-rust-sdk

Matrix Client-Server SDK for Rust
Apache License 2.0
1.19k stars 236 forks source link

SQLite store blocks login after logout #3270

Open twilight-flower opened 6 months ago

twilight-flower commented 6 months ago

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.

bnjbvr commented 6 months ago

Thanks for opening an issue! Sounds like a good idea to me :+1: Would you be interested in opening a PR?

twilight-flower commented 6 months ago

At the moment I don't think I've got the slack to learn the SDK's internal codebase well enough to make a useful PR, unfortunately.

bnjbvr commented 6 months ago

No worries, thanks for opening the issue.