Skip to content

logout feature #432

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 36 commits into
base: main
Choose a base branch
from

Conversation

TigerInYourDream
Copy link

Based on PR #293, I found an error message during logout:
2024-12-24T07:58:55.514036Z ERROR matrix_sdk_ui::sync_service: Error while processing encryption in sync service: Something wrong happened in sliding sync: the server returned an error: [401 / M_UNKNOWN_TOKEN] Invalid access token passed.
Root cause:
The error is related to SYNC_SERVICE handling during logout process.

Changes:

  • Updated SYNC_SERVICE handling during logout
  • Tested the fix with Google SSO login/logout flow

@kevinaboos
Copy link
Member

Thanks Alvin. I'm a bit confused -- is this a replacement for #293, or something that should be merged in after #293 as an addition to it?

Also, is it ready for review or shall I wait for something else?

@TigerInYourDream
Copy link
Author

Thanks Alvin. I'm a bit confused -- is this a replacement for #293, or something that should be merged in after #293 as an addition to it?

Also, is it ready for review or shall I wait for something else?

Due to the age of PR #293 and substantial changes in the codebase, resolving merge conflicts became quite challenging. I've contacted the original author, Guocork, who also suggested creating a new PR. Therefore, I've created a fresh PR implementing the same functionality with updated code and comprehensive testing. Could you please review this new implementation?

Copy link
Member

@kevinaboos kevinaboos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Alvin, great start on this feature!

I left some comments below. In general, make sure to name things carefully --- try to give variables and types very specific names that cannot be misinterpreted. (I know naming is hard, so it'll take some time to get that right. No worries.)

@kevinaboos kevinaboos added the waiting-on-author This issue is waiting on the original author for a response label Mar 12, 2025
@TigerInYourDream
Copy link
Author

Thanks Alvin, great start on this feature!

I left some comments below. In general, make sure to name things carefully --- try to give variables and types very specific names that cannot be misinterpreted. (I know naming is hard, so it'll take some time to get that right. No worries.)

Thank you for the review. I will try to improve the naming conventions and continue working on it.

@TigerInYourDream TigerInYourDream marked this pull request as draft March 13, 2025 04:50
@TigerInYourDream TigerInYourDream marked this pull request as ready for review March 18, 2025 07:24
@alanpoon
Copy link
Contributor

alanpoon commented Mar 18, 2025

  1. Suggest adding a modal for logout confirmation
  2. Perhaps delete the "latest_user_id.txt" in the app data directory
  3. After logout, restarting the app will see a prompt saying fail to "Could not restore previous user session"
    Screenshot 2025-03-18 at 3 51 49 PM

@TigerInYourDream
Copy link
Author

  1. Suggest adding a modal for logout confirmation
  2. Perhaps delete the "latest_user_id.txt" in the app data directory
  3. After logout, restarting the app will see a prompt saying fail to "Could not restore previous user session"
    Screenshot 2025-03-18 at 3 51 49 PM

Thanks for the review.

@TigerInYourDream TigerInYourDream changed the title fix pr #293 about logout logout feature Mar 21, 2025
}
}
}

if let Some(LoginAction::LoginSuccess) = action.downcast_ref() {
log!("Received LoginAction::LoginSuccess, hiding login view.");
self.app_state.logged_in = true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need to call cx.action(RoomsPanelAction::DockLoad); To restore User's previous Dock state, as you cx.action(RoomsPanelAction::DockLoad) when login out.

Comment on lines 234 to 235
WidgetUid(0),
&Scope::empty().path,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use either self.widget_uid().
use scope.path when there is scope.



impl LogoutConfirmModalRef {
/// See [`LogoutConfirmModal::set_message()`].
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For document linking, LogoutConfirmModal::set_message needs to be public function.

@alanpoon
Copy link
Contributor

alanpoon commented May 2, 2025

It is might better using Tokio's shutdown background to close all asynchronous task.
I have asked AI about it and I have asked vaguely tried it. It looks promising and have lesser code changes.
b.txt
Perhaps timeout with arbitrary duration can be removed.

@alanpoon alanpoon closed this May 2, 2025
@alanpoon alanpoon reopened this May 2, 2025
src/app.rs Outdated
Comment on lines 409 to 420

pub fn show_logout_confirm_modal(&self, cx: &mut Cx) {
let modal = self.ui.modal(id!(logout_confirm_modal));
modal.open(cx);
}

pub fn hide_logout_confirm_modal(&self, cx: &mut Cx) {
let modal = self.ui.modal(id!(logout_confirm_modal));
log!("Got modal reference for hiding: {:?}", modal);
modal.close(cx);
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just a simple wrapper around the modal's open and hide methods. I feel like we can just call self.ui.modal(id!(logout_confirm_modal)).open() or hide() directly, without adding extra wrappers.

@Guocork
Copy link
Contributor

Guocork commented May 8, 2025

I once implemented a modal for Moly: https://github.com/moxin-org/moly/pull/341/files.
There is a very simple modal in Moly: https://github.com/moxin-org/moly/blob/main/src/shared/modal.rs
you can check out both of these for reference.

@TigerInYourDream
Copy link
Author

It is might better using Tokio's shutdown background to close all asynchronous task. I have asked AI about it and I have asked vaguely tried it. It looks promising and have lesser code changes. b.txt Perhaps timeout with arbitrary duration can be removed.

I opted against using both shutdown_background and shutdown_timeout because they immediately begin closing the Tokio runtime, which causes subsequent async tasks to fail. Our logout flow still requires the runtime for critical operations like cleaning up state and sending notifications after the core tasks are aborted. I tested both shutdown methods and they proved problematic, resulting in incomplete logout processes where the application wouldn't properly transition to the login state.

@alanpoon
Copy link
Contributor

It is might better using Tokio's shutdown background to close all asynchronous task. I have asked AI about it and I have asked vaguely tried it. It looks promising and have lesser code changes. b.txt Perhaps timeout with arbitrary duration can be removed.

I opted against using both shutdown_background and shutdown_timeout because they immediately begin closing the Tokio runtime, which causes subsequent async tasks to fail. Our logout flow still requires the runtime for critical operations like cleaning up state and sending notifications after the core tasks are aborted. I tested both shutdown methods and they proved problematic, resulting in incomplete logout processes where the application wouldn't properly transition to the login state.

I don't see what issue there is https://github.com/alanpoon/robrix/tree/fix-logout-shutdown. The issue is that your "logout_successful = true" is inside successful response of client.matrix_auth().logout() which is not necessary. If the access token is invalid -> client.matrix_auth().logout() will fail. But access token is invalid is also logged out state.

@aaravlu aaravlu added waiting-on-review This issue is waiting to be reviewed and removed waiting-on-author This issue is waiting on the original author for a response labels May 29, 2025
@kevinaboos
Copy link
Member

I noticed that my review has been requested here and that this has been marked as waiting-on-review. However, there's also another PR #494 that seems to supersede this.

Can you guys clarify the relationship between these PRs and which one I should be looking at?

@kevinaboos kevinaboos added waiting-on-author This issue is waiting on the original author for a response and removed waiting-on-review This issue is waiting to be reviewed labels May 29, 2025
@TigerInYourDream
Copy link
Author

Regarding PR494, I had a discussion with @alanpoon about which method to use for terminating asynchronous tasks in Tokio. After our discussion, we concluded that using shutdown_background would make this PR more concise and efficient.

As a result, I have updated the original code to implement the shutdown_background version. This change simplifies the task termination process while maintaining the desired functionality.

I kindly request a review of the current PR to ensure that the implementation aligns with our project standards and effectively addresses the task termination requirements.

Your feedback on this updated approach would be greatly appreciated. Please let me know if you need any further information or clarification on the changes made.

Thank you for your time and consideration. @kevinaboos

@kevinaboos
Copy link
Member

Ok, that adds a bit of detail, but doesn't fully answer my question. Is #494 being closed? Is this being merged in and then #494 afterwards? @alanpoon's previous comments seem to indicate that the approach hasn't been settled on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
waiting-on-author This issue is waiting on the original author for a response
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants