Ejemplo n.º 1
0
        protected override async Task OnAfterRenderAsync(bool firstRender)
        {
            await base.OnAfterRenderAsync(firstRender).ConfigureAwait(false);

            if (firstRender)
            {
                CanRender   = true;
                AuthSession = await ProtectedBrowserStore.GetAsync <AuthorizationSession>(StaticLiterals.AuthorizationSessionKey).ConfigureAwait(false);
            }
        }
Ejemplo n.º 2
0
        protected async Task ClearPageHistoryAsync()
        {
            var localSessionHistory = await ProtectedBrowserStore.GetAsync <SessionHistory>(StaticLiterals.SessionHistoryKey).ConfigureAwait(false);

            if (localSessionHistory != null)
            {
                localSessionHistory.ClearHistory();
                await ProtectedBrowserStore.SetAsync(StaticLiterals.SessionHistoryKey, localSessionHistory).ConfigureAwait(false);
            }
        }
Ejemplo n.º 3
0
        protected async Task <string> GetPageBeforeLoginAsync()
        {
            var result = await ProtectedBrowserStore.GetAsync <string>(StaticLiterals.BeforeLoginPageKey).ConfigureAwait(false);

            if (string.IsNullOrEmpty(result))
            {
                result = "/";
            }
            else if (result.StartsWith("/") == false)
            {
                result = $"/{result}";
            }
            return(result);
        }
Ejemplo n.º 4
0
        protected override async void HandleLocationChanged(object sender, LocationChangedEventArgs e)
        {
            base.HandleLocationChanged(sender, e);

            var shortLocationUrl    = e.Location.Replace(NavigationManager.BaseUri, "/");
            var localSessionHistory = await ProtectedBrowserStore.GetAsync <SessionHistory>(StaticLiterals.SessionHistoryKey).ConfigureAwait(false);

            if (localSessionHistory == null)
            {
                localSessionHistory = new SessionHistory();
            }

            if (localSessionHistory.PeekHistory().Equals(shortLocationUrl) == false)
            {
                localSessionHistory.PushHistory(shortLocationUrl.Equals($"/{StaticLiterals.LoginPage}") ? "/" : shortLocationUrl);
                await ProtectedBrowserStore.SetAsync(StaticLiterals.SessionHistoryKey, localSessionHistory).ConfigureAwait(false);

                HasLocationChanged = true;
            }
        }
Ejemplo n.º 5
0
 protected async Task SetPageBeforeLoginAsync(string pageName)
 {
     await ProtectedBrowserStore.SetAsync(StaticLiterals.BeforeLoginPageKey, pageName).ConfigureAwait(false);
 }
Ejemplo n.º 6
0
 protected async Task ClearPageBeforeLoginAsync()
 {
     await ProtectedBrowserStore.SetAsync(StaticLiterals.BeforeLoginPageKey, string.Empty).ConfigureAwait(false);
 }