예제 #1
0
        private static async Task LogOutIfNeeded(HttpContext context)
        {
            if (context.User.Identity.IsAuthenticated)
            {
                string nickName = context.User.Identity.Name;

                // if the user has to be logged out by force, do that now
                if (ApplicationAdapter.UserHasToBeLoggedOutByForce(nickName))
                {
                    await context.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme);

                    context.Session.Clear();
                    context.Response.Redirect(ApplicationAdapter.GetVirtualRoot());
                    ApplicationAdapter.RemoveUserFromListToBeLoggedOutByForce(nickName);
                }
            }
        }
예제 #2
0
        private static async Task RedirectToInitIfRequired(HttpContext context)
        {
            // check if there's an anonymous user in the database
            var anonymous = await UserGuiHelper.GetUserAsync(0);             // use hardcoded 0 id. This also makes sure a misconfigured db isn't used further.

            if (anonymous == null)
            {
                // database is empty
                context.Request.Path = ApplicationAdapter.GetVirtualRoot() + "Admin/Init";
            }
            else
            {
                if (anonymous.NickName != "Anonymous")
                {
                    // Misconfigured.
                    context.Request.Path = ApplicationAdapter.GetVirtualRoot() + "Error/1337";
                }
            }
        }