public async Task <CheckIfCanCreateAdminUserResponse> CheckIfCanCreateAdminUser()
        {
            var response = new CheckIfCanCreateAdminUserResponse();

            var adminCheckResponse = await _adminManager.CheckForAdminUser();

            if (adminCheckResponse.AdminUserExists)
            {
                response.Notifications.AddError("Admin already exists");
            }
            return(response);
        }
Пример #2
0
        public async Task Invoke(HttpContext context, IAdminManager adminManager)
        {
            // check if an admin user exists
            var response = await adminManager.CheckForAdminUser();

            if (!response.AdminUserExists && context.Request.Path != "/Admin/CreateAdminUser")
            {
                context.Response.Redirect("/Admin/CreateAdminUser");
            }

            // Call the next delegate/middleware in the pipeline
            await _next(context);
        }