diff options
| author | Andrej Mihajlov <and@mullvad.net> | 2018-09-07 16:17:29 +0300 |
|---|---|---|
| committer | Andrej Mihajlov <and@mullvad.net> | 2018-09-07 19:14:06 +0300 |
| commit | 194e953e45b97d00ae278a615cb601fe81da7cc4 (patch) | |
| tree | 569ec4a979eb1dccdf7ba5eac43640c99b7bfaee | |
| parent | 76097e4eadd4334b9a390be85acdebbdd3f6e706 (diff) | |
| download | mullvadvpn-194e953e45b97d00ae278a615cb601fe81da7cc4.tar.xz mullvadvpn-194e953e45b97d00ae278a615cb601fe81da7cc4.zip | |
Hack the history to prevent user from coming to restricted screens
| -rw-r--r-- | gui/packages/desktop/src/renderer/app.js | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/gui/packages/desktop/src/renderer/app.js b/gui/packages/desktop/src/renderer/app.js index 4fb7952435..1e2ead161d 100644 --- a/gui/packages/desktop/src/renderer/app.js +++ b/gui/packages/desktop/src/renderer/app.js @@ -180,6 +180,14 @@ export default class AppRenderer { // take user to main view if user is still at launch screen `/` if (history.location.pathname === '/') { actions.history.replace('/connect'); + } else { + // TODO: Reinvent the navigation back in history to make sure that user does not end up on + // the restricted screen due to changes in daemon's state. + for (const entry of history.entries) { + if (entry.pathname === '/') { + entry.pathname = '/connect'; + } + } } } else { log.debug('No account set, showing login view.'); @@ -190,6 +198,14 @@ export default class AppRenderer { // take user to `/login` screen if user is at launch screen `/` if (history.location.pathname === '/') { actions.history.replace('/login'); + } else { + // TODO: Reinvent the navigation back in history to make sure that user does not end up on + // the restricted screen due to changes in daemon's state. + for (const entry of history.entries) { + if (!entry.pathname.startsWith('/settings')) { + entry.pathname = '/login'; + } + } } } } @@ -489,8 +505,13 @@ export default class AppRenderer { // take user back to the launch screen `/` except when user is in settings. if (history.location.pathname.startsWith('/settings')) { - // TODO: make sure that user can still access settings but returning from settings should - // take user to launch screen `/`. + // TODO: Reinvent the navigation back in history to make sure that user does not end up on + // the restricted screen due to changes in daemon's state. + for (const entry of history.entries) { + if (!entry.pathname.startsWith('/settings')) { + entry.pathname = '/'; + } + } } else { actions.history.replace('/'); } |
