Skip to content
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

Delete DeviceID after Logout / Recreate on Login #32

Open
luke- opened this issue Nov 12, 2023 · 4 comments
Open

Delete DeviceID after Logout / Recreate on Login #32

luke- opened this issue Nov 12, 2023 · 4 comments
Assignees
Labels
enhancement New feature or request

Comments

@luke-
Copy link
Contributor

luke- commented Nov 12, 2023

#30 (comment)

@luke- luke- added the enhancement New feature or request label Nov 12, 2023
@luke- luke- self-assigned this Nov 12, 2023
@luke- luke- assigned marc-farre and unassigned luke- Dec 24, 2024
@luke-
Copy link
Contributor Author

luke- commented Dec 24, 2024

@marc-farre If you have some time (not critical), can you check out how logouts and push tokens work?
Maybe we should implement a cleanup for old tokens, especially in the long term.

@marc-farre
Copy link
Contributor

@luke- With the mobile app, token registering/unregistering is fine.

But with the web browser, only registering is done:

  1. https://github.com/humhub/humhub/blob/8ebff629765ad6aa678fe8290e5f743e8fbf9439/protected/humhub/modules/web/pwa/widgets/LayoutHeader.php#L65-L65
  2. function afterServiceWorkerRegistration(registration) {
  3. const sendTokenToServer = function (token) {
  4. public function actionUpdate()

But for unregistering the token, I started a PR, because I think we need to do it using the BEFORE_LOGOUT event:
https://github.com/humhub/fcm-push/pull/63/files#diff-666c020a6d1e6a59ba261ba9316aaa19e27dbd851bcc4fdcaecaa278ddc96c10R141

But the humhub.modules.firebase.unregisterNotification(); function is not done in this PR, because I don't know how to get the token of the current session (we need to delete the token of browser session, but the ones of the other browsers).
If you know how to retrieve it, I can finish this PR. Thanks!

@luke-
Copy link
Contributor Author

luke- commented Jan 6, 2025

@marc-farre

I think we could retrieve the FirebaseToken of the current browser session via LocalStorage.

Not sure, but maybe humhub.modules.firebase.unregisterNotification(); could work like this:

  1. Get Firebase Token https://github.com/humhub/fcm-push/blob/master/resources/js/humhub.firebase.js#L83
  2. Send to new Delete Action similar to: https://github.com/humhub/fcm-push/blob/master/controllers/TokenController.php#L76
  3. Locally unregister Token: https://github.com/humhub/fcm-push/blob/master/resources/js/humhub.firebase.js#L71

What do you think?

@marc-farre
Copy link
Contributor

@luke- Thanks! I was looking for something complicated, but indeed, getTokenLocalStore was already implemented!

Now PR #63 is working as intended.

Should I add an integrity check to delete all tokens older than the "Default user idle timeout, auto-logout" value?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants