Cannot visit more than one shared link #1806

Closed
opened 2021-07-09 16:26:07 +00:00 by andreymal · 6 comments
Contributor

Steps to reproduce:

  1. Get two different shared links on same Vikunja instance
  2. Visit first link
  3. Then visit second link

Instead of opening, the fronend hangs on "Authenticating…" and does nothing because of this return (state.auth contains information about the previous shared link).

(A quick fix would be automatic logout when opening different shared link, but I guess this has deeper roots because shared links reuse the same authentication mechanism as regular users. As a consequence, if a registered user visits a shared link, the user is automatically logged out because jwt is being replaced by the shared link — this is a bad UX. I suspect that the authentication mechanism needs to be reworked, but I have no idea how to do it best, so I just leave this note here.)

Steps to reproduce: 1. Get two different shared links on same Vikunja instance 2. Visit first link 3. Then visit second link Instead of opening, the fronend hangs on "Authenticating…" and does nothing because of [this return](https://kolaente.dev/vikunja/frontend/src/commit/f0498fd767a9df1c1f89e21b2a2606377f455a0d/src/views/sharing/LinkSharingAuth.vue#L64-L65) (state.auth contains information about the previous shared link). (A quick fix would be automatic logout when opening different shared link, but I guess this has deeper roots because shared links reuse the same authentication mechanism as regular users. As a consequence, if a registered user visits a shared link, the user is automatically logged out because jwt is being replaced by the shared link — this is a bad UX. I suspect that the authentication mechanism needs to be reworked, but I have no idea how to do it best, so I just leave this note here.)
Owner

Ideally you would be able to visit multiple links simultaniously without them overriding each other. As you pointed out, that's not that easy to fix because all api connections assume an authentication token stored in local storage which is shared per domain and not per tab. To fix this, it would need to only store the auth token in memory, but only for link shares and then pass it along. Would require quite some refactoring of the way the api connection is currently implemented.

Ideally you would be able to visit multiple links simultaniously without them overriding each other. As you pointed out, that's not that easy to fix because all api connections assume an authentication token stored in local storage which is shared per domain and not per tab. To fix this, it would need to only store the auth token in memory, but only for link shares and then pass it along. Would require quite some refactoring of the way the api connection is currently implemented.
konrad added the
kind/bug
kind/feature
labels 2021-07-09 17:04:00 +00:00
Owner

Turns out, this is a lot less hard than I thought.

I've implemented a change in a787f6ffc7 which saves auth tokens from link shares in memory only, enabling to view multiple link shares in the same browser without them interfering each other (or a logged in user in the same browser).
I'm closing this issue as it is resolved, feel free to reopen if you have any other problems with it.

Turns out, this is a lot less hard than I thought. I've implemented a change in a787f6ffc79d6234f58868b3815c33b73d7d9952 which saves auth tokens from link shares in memory only, enabling to view multiple link shares in the same browser without them interfering each other (or a logged in user in the same browser). I'm closing this issue as it is resolved, feel free to reopen if you have any other problems with it.
Author
Contributor

@konrad it seems I caught a race: the user/token and shares/.../auth requests are sent at almost same time, and the authorization result depends on which response comes last

@konrad it seems I caught a race: the `user/token` and `shares/.../auth` requests are sent at almost same time, and the authorization result depends on which response comes last
Owner

I've added a timout for renewing the token in 20fd25e280 which should fix that.

I've added a timout for renewing the token in 20fd25e2809b332680270faccd4bd15ef95a2145 which should fix that.
Author
Contributor

Now it works 👍
Seems the logout button is no longer needed? Removing it will make shared pages look a bit nicer

Now it works 👍 Seems the logout button is no longer needed? Removing it will make shared pages look a bit nicer
Owner

Yeah I think that makes sense (f0e093b3d6)

Yeah I think that makes sense (f0e093b3d6a1ddb293715bd1bc90becc11b3a67e)
Sign in to join this conversation.
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: vikunja/vikunja#1806
No description provided.