private async Task <string> RenderBootstrapperAsync(AngularModuleRouteLibrary routeLibrary, object options) { var args = string.Empty; if (_hostingEnvironment.IsDevelopment()) { // use strict DI when in debug mode to throw up errors args = ", { strictDi: true }"; } // Might need to add more info at some point, but right now we just need roles. var user = await _userContextService.GetCurrentContextByUserAreaAsync(CofoundryAdminUserArea.AreaCode); var role = await _queryExecutor.ExecuteAsync(new GetRoleDetailsByIdQuery(user.RoleId)); var currentUserInfo = new { PermissionCodes = role .Permissions .Select(p => p.GetUniqueCode()) .ToList() }; var tokens = _antiforgery.GetAndStoreTokens(_httpContextAccessor.HttpContext); var canShowDeveloperException = _debugSettings.CanShowDeveloperExceptionPage(_hostingEnvironment); return(@"<script>angular.element(document).ready(function() { angular.module('" + _adminRouteLibrary.Shared.Angular.AngularModuleName + @"') .constant('csrfToken', '" + tokens.RequestToken + @"') .constant('csrfHeaderName', '" + tokens.HeaderName + @"')" + GetConstant(_adminRouteLibrary.Shared, "showDevException", canShowDeveloperException) + GetConstant(routeLibrary, "options", options) // not sure why the current module is loaded into the shared module - seems like a mistake? + GetConstant(_adminRouteLibrary.Shared, "currentUser", currentUserInfo) + @"; angular.bootstrap(document, ['" + routeLibrary.Angular.AngularModuleName + "']" + args + @"); });</script>"); }
public void Configure(IApplicationBuilder app) { var env = app.ApplicationServices.GetService<IHostingEnvironment>(); if (_debugSettings.CanShowDeveloperExceptionPage(env)) { app.UseDeveloperExceptionPage(); app.UseDatabaseErrorPage(); } else { app.UseExceptionHandler(CofoundryErrorController.ExceptionHandlerPath); } app.UseStatusCodePagesWithReExecute(CofoundryErrorController.StatusCodePagesRoute); }
private async Task <string> RenderBootstrapperAsync(AngularModuleRouteLibrary routeLibrary, object options) { var args = string.Empty; if (_webHostEnvironment.IsDevelopment()) { // use strict DI when in debug mode to throw up errors args = ", { strictDi: true }"; } var user = await _userContextService.GetCurrentContextByUserAreaAsync(CofoundryAdminUserArea.Code); var role = await _queryExecutor.ExecuteAsync(new GetRoleDetailsByIdQuery(user.RoleId)); var currentUserInfo = new { UserId = user.UserId, IsSuperAdmin = user.IsSuperAdmin(), PermissionCodes = role .Permissions .Select(p => p.GetUniqueIdentifier()) .ToList() }; var tokens = _antiforgery.GetAndStoreTokens(_httpContextAccessor.HttpContext); var canShowDeveloperException = _debugSettings.CanShowDeveloperExceptionPage(_webHostEnvironment); return(@"<script>angular.element(document).ready(function() { angular.module('" + _adminRouteLibrary.Shared.Angular.AngularModuleName + @"') .constant('csrfToken', '" + tokens.RequestToken + @"') .constant('csrfHeaderName', '" + tokens.HeaderName + @"')" + GetConstant(_adminRouteLibrary.Shared, "showDevException", canShowDeveloperException) + GetConstant(_adminRouteLibrary.Shared, "serviceBase", "/" + _adminSettings.DirectoryName + "/api/") + GetConstant(_adminRouteLibrary.Shared, "pluginServiceBase", "/" + _adminSettings.DirectoryName + "/api/plugins/") + GetConstant(_adminRouteLibrary.Shared, "urlBaseBase", "/" + _adminSettings.DirectoryName + "/") + GetConstant(_adminRouteLibrary.Shared, "internalContentPath", _adminRouteLibrary.Shared.GetStaticResourceUrlPath() + "/") + GetConstant(_adminRouteLibrary.Shared, "pluginContentPath", _adminRouteLibrary.SharedPlugin.GetStaticResourceUrlPath() + "/") + GetConstant(_adminRouteLibrary.Shared, "contentPath", _adminRouteLibrary.SharedAlternate.GetStaticResourceUrlPath() + "/") + GetConstant(routeLibrary, "options", options) // not sure why the current module is loaded into the shared module - seems like a mistake? + GetConstant(_adminRouteLibrary.Shared, "currentUser", currentUserInfo) + @"; angular.bootstrap(document, ['" + routeLibrary.Angular.AngularModuleName + "']" + args + @"); });</script>"); }