From d14071f3503f768c9c0e040dee549be6a6b40e5f Mon Sep 17 00:00:00 2001 From: vantezzen Date: Tue, 17 Sep 2019 12:14:48 +0200 Subject: Implement #41 --- src/stores/SettingsStore.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'src/stores/SettingsStore.js') diff --git a/src/stores/SettingsStore.js b/src/stores/SettingsStore.js index 2975499b3..f6a53f147 100644 --- a/src/stores/SettingsStore.js +++ b/src/stores/SettingsStore.js @@ -62,6 +62,34 @@ export default class SettingsStore extends Store { this.all.app.autohideMenuBar, ), ); + + reaction( + () => this.all.app.locked, + () => { + const { router } = window.ferdi.stores; + + if (this.all.app.locked && this.all.app.lockingFeatureEnabled) { + // App just got locked, redirect to unlock screen + router.push('/auth/locked'); + } else if (router.location.pathname.includes('/auth/locked')) { + // App is unlocked but user is still on locked screen + // Redirect to homepage + router.push('/'); + } + }, + ); + + // Make sure to lock app on launch if locking feature is enabled + setTimeout(() => { + if (this.all.app.lockingFeatureEnabled) { + this.actions.settings.update({ + type: 'app', + data: { + locked: true, + }, + }); + } + }, 1000); } @computed get app() { -- cgit v1.2.3-54-g00ecf