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

[bug] Page deep-links and browser reloads always switch to control panel #675

Closed
ahochsteger opened this issue Feb 22, 2021 · 15 comments · Fixed by #854
Closed

[bug] Page deep-links and browser reloads always switch to control panel #675

ahochsteger opened this issue Feb 22, 2021 · 15 comments · Fixed by #854
Assignees
Labels
bug Something isn't working

Comments

@ahochsteger
Copy link
Collaborator

Version

Build/Run method: Docker
zwavejs2mqtt version: 1.2.2
zwavejs version: 6.4.0

Describe the bug

When I reload a page other than the control panel it always switches back to the control panel.

To Reproduce

Steps to reproduce the behavior for browser reload:

  1. Go to any page other than the control panel (e.g. the settings page)
  2. Click on reload in the browser
  3. The browser changes the URL to the control panel

Steps to reproduce the behavior for deep-linking:

  1. Open a direct link to any page other than the control panel (e.g. .../settings)
  2. The browser changes the URL to the control panel

Expected behavior

The browser should keep the current URL on reload or stay at the given URL when using a direct link.

Additional context

It seems that this behavior change has been introduced with #591 and #640.

@ahochsteger ahochsteger added the bug Something isn't working label Feb 22, 2021
@ahochsteger
Copy link
Collaborator Author

ahochsteger commented Feb 22, 2021

The fix will also be required to be able to allow more fine-grained deep links for z2m in the future e.g. direct link to certain nodes or tabs in the control panel to allow switching between mesh graph and control panel or direct link from other smart home systems to manage a specific node.

@robertsLando
Copy link
Member

robertsLando commented Feb 22, 2021

The fix will also be required to be able to allow more fine-grained deep links for z2m in the future e.g. direct link to certain nodes or tabs in the control panel to allow switching between mesh graph and control panel or direct link from other smart home systems to manage a specific node.

This would require to use query in url or the anchor

@robertsLando
Copy link
Member

About the main issue, I think this is something that only happens in production right? as I'm not able to repro this in my dev env

@robertsLando
Copy link
Member

I'm unable to reproduce this on my instance in dev or production env 🤷‍♂️

@ahochsteger
Copy link
Collaborator Author

ahochsteger commented Feb 28, 2021

@robertsLando sorry, for the late reply - here is some more information that may help to reproduce the issue:

  • I can reproduce the issue in production (rpi4 using docker) as well as running it on a dev setup (without docker)
  • I have the internal auth mechanism disabled, since I'm using traefik with forwarded auth to Google Authentication instead for all of my apps (but not on my dev setup)
  • When I enter the URL /settings I can see redirects to / and then to /control-panel in the address bar of the browser

Did you try to reproduce it with auth enabled? I suspect that this behavior has been introduced with the auth changes.

@ahochsteger ahochsteger reopened this Feb 28, 2021
@ahochsteger ahochsteger self-assigned this Mar 1, 2021
@ahochsteger
Copy link
Collaborator Author

@robertsLando I just found some time to debug this issue and added some logs to output variables that affect the control flow. This is the log output when accessing the settings page:

Navigated to http://localhost:8092/settings
index.js?a18c:150 beforeEach(): user.notLogged: true ,route.auth: true ,to.fullPath: /settings , from: {name: null, meta: {…}, path: "/", hash: "", query: {…}, …}
index.js?a18c:150 beforeEach(): user.notLogged: true ,route.auth: false ,to.fullPath: / , from: {name: null, meta: {…}, path: "/", hash: "", query: {…}, …}
App.vue?c65d:500 checkAuth() newAuth: false , oldAuth: undefined , this.$route.path: /

I'm not really sure about the meaning of all variables but as you can see the router redirects form /settings to / and stays there.

It's only happening, if auth is disabled (since I offload auth to traefik). When auth is enabled this is not happening.

@robertsLando
Copy link
Member

I think your problem could be that the user is not found in localstorage, this happens in router/index in beforeeach functuon, I suggest you to put a breakpoint there and see if the user is found

@ahochsteger
Copy link
Collaborator Author

Yes, there is no user found in localStorage, but I don't get why it should find one, since I'm running zjs2m with authentication disabled (as I already pointed out before).
These are the log outputs from the relevant locations:

beforeEach() store.state.user: {__ob__: Observer}__ob__: Observer {value: {…}, dep: Dep, vmCount: 0}__proto__: Object
beforeEach() user(from localStorage): null
beforeEach() user: {}

@robertsLando
Copy link
Member

Sorry I misunderstood the problem, I thought the problem was with auth enabled. Let me check this again

@robertsLando
Copy link
Member

I have submitted a fix for this, try it out

@ahochsteger
Copy link
Collaborator Author

@robertsLando, yes it solves the reload problem with auth deactivated :-).

@robertsLando
Copy link
Member

It should also don't break when it is enabled. Could you double check? :)

@ahochsteger
Copy link
Collaborator Author

@robertsLando it works with auth enabled and disabled :-).
What I don't understand is, why there is some difference when auth is disabled that causes opening /settings to redirect to / and than back to /settings. Are they required?
I don't see these redirects when auth is enabled.

@robertsLando
Copy link
Member

robertsLando commented Mar 9, 2021

This happens when both auth is enabled and disabled, the problem is that when the page is firstly loaded I dunno if auth is enabled or not so by default I redirect user to / (Login) because if I load some other route that will try to bind socket events and other stuff that will throw many errors (as socket isn't inited until I know if I need to use auth or not) but you don't see it because there is the overlay. Once I get the answer from the server if the auth is enabled or not I redirect the user to the firstly requested page. The problem here is to rremember the first route loaded, this is done by route params nextUrl but that seems not working when auth is disabled (I tried everything, there should be a solution but I ended up using localstorage to don't get crazy)

@ahochsteger
Copy link
Collaborator Author

I see - so you're currently using a workaround to solve this problem until a better solution can be found.
Thanks - it works now again as expected :-).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants