Exemple #1
0
        private async Task SetMainPageAsync()
        {
            var authed = await _stateService.IsAuthenticatedAsync();

            if (authed)
            {
                if (await _vaultTimeoutService.IsLoggedOutByTimeoutAsync() ||
                    await _vaultTimeoutService.ShouldLogOutByTimeoutAsync())
                {
                    // TODO implement orgIdentifier flow to SSO Login page, same as email flow below
                    // var orgIdentifier = await _stateService.GetOrgIdentifierAsync();

                    var email = await _stateService.GetEmailAsync();

                    Options.HideAccountSwitcher = await _stateService.GetActiveUserIdAsync() == null;

                    Current.MainPage = new NavigationPage(new LoginPage(email, Options));
                }
                else if (await _vaultTimeoutService.IsLockedAsync() ||
                         await _vaultTimeoutService.ShouldLockAsync())
                {
                    Current.MainPage = new NavigationPage(new LockPage(Options));
                }
                else if (Options.FromAutofillFramework && Options.SaveType.HasValue)
                {
                    Current.MainPage = new NavigationPage(new AddEditPage(appOptions: Options));
                }
                else if (Options.Uri != null)
                {
                    Current.MainPage = new NavigationPage(new AutofillCiphersPage(Options));
                }
                else if (Options.CreateSend != null)
                {
                    Current.MainPage = new NavigationPage(new SendAddEditPage(Options));
                }
                else
                {
                    Current.MainPage = new TabsPage(Options);
                }
            }
            else
            {
                Options.HideAccountSwitcher = await _stateService.GetActiveUserIdAsync() == null;

                if (await _vaultTimeoutService.IsLoggedOutByTimeoutAsync() ||
                    await _vaultTimeoutService.ShouldLogOutByTimeoutAsync())
                {
                    // TODO implement orgIdentifier flow to SSO Login page, same as email flow below
                    // var orgIdentifier = await _stateService.GetOrgIdentifierAsync();

                    var email = await _stateService.GetEmailAsync();

                    Current.MainPage = new NavigationPage(new LoginPage(email, Options));
                }
                else
                {
                    Current.MainPage = new NavigationPage(new HomePage(Options));
                }
            }
        }
Exemple #2
0
        public async Task NavigateOnAccountChangeAsync(bool?isAuthed = null)
        {
            // TODO: this could be improved by doing chain of responsability pattern
            // but for now it may be an overkill, if logic gets more complex consider refactoring it

            var authed = isAuthed ?? await _stateService.IsAuthenticatedAsync();

            if (authed)
            {
                if (await _vaultTimeoutService.IsLoggedOutByTimeoutAsync() ||
                    await _vaultTimeoutService.ShouldLogOutByTimeoutAsync())
                {
                    // TODO implement orgIdentifier flow to SSO Login page, same as email flow below
                    // var orgIdentifier = await _stateService.GetOrgIdentifierAsync();

                    var email = await _stateService.GetEmailAsync();

                    Options.HideAccountSwitcher = await _stateService.GetActiveUserIdAsync() == null;

                    _accountsManagerHost.Navigate(NavigationTarget.Login, new LoginNavigationParams(email));
                }
                else if (await _vaultTimeoutService.IsLockedAsync() ||
                         await _vaultTimeoutService.ShouldLockAsync())
                {
                    _accountsManagerHost.Navigate(NavigationTarget.Lock);
                }
                else if (Options.FromAutofillFramework && Options.SaveType.HasValue)
                {
                    _accountsManagerHost.Navigate(NavigationTarget.AddEditCipher);
                }
                else if (Options.Uri != null)
                {
                    _accountsManagerHost.Navigate(NavigationTarget.AutofillCiphers);
                }
                else if (Options.CreateSend != null)
                {
                    _accountsManagerHost.Navigate(NavigationTarget.SendAddEdit);
                }
                else
                {
                    _accountsManagerHost.Navigate(NavigationTarget.Home);
                }
            }
            else
            {
                Options.HideAccountSwitcher = await _stateService.GetActiveUserIdAsync() == null;

                if (await _vaultTimeoutService.IsLoggedOutByTimeoutAsync() ||
                    await _vaultTimeoutService.ShouldLogOutByTimeoutAsync())
                {
                    // TODO implement orgIdentifier flow to SSO Login page, same as email flow below
                    // var orgIdentifier = await _stateService.GetOrgIdentifierAsync();

                    var email = await _stateService.GetEmailAsync();

                    _accountsManagerHost.Navigate(NavigationTarget.Login, new LoginNavigationParams(email));
                }
                else
                {
                    _accountsManagerHost.Navigate(NavigationTarget.HomeLogin);
                }
            }
        }