/// <summary> /// Displays the login page. /// </summary> private async Task <ActionResult> ViewLoginFormAsync(LoginStatus?status, string returnUrl = null) { ViewBag.Data = new LoginDataVM { ReturnUrl = returnUrl, AllowGuests = _cfgProvider.GetDynamicConfig().AllowGuests, AllowPasswordAuth = _cfgProvider.GetStaticConfig().Auth.AllowPasswordAuth, Providers = _provs.AvailableProviders, IsFirstUser = await _auth.IsFirstUserAsync(), Status = status }; return(View(new LocalLoginVM())); }
/// <summary> /// Checks the authorization if the config requires it. /// </summary> protected override async Task HandleRequirementAsync(AuthorizationHandlerContext context, AuthRequirement requirement) { var cfg = _cfgProvider.GetDynamicConfig(); if (cfg.AllowGuests) { context.Succeed(requirement); return; } var user = await _userMgr.GetUserAsync(context.User); if (user?.IsValidated == true) { context.Succeed(requirement); } }
/// <summary> /// Renders the tree using ELK.js. /// </summary> private async Task <string> RenderTree(INodeServices js, TreeLayoutVM tree) { var thoroughness = Interpolator.MapValue( _config.GetDynamicConfig().TreeRenderThoroughness, new IntervalMap(1, 10, 1, 10), new IntervalMap(11, 50, 11, 600), new IntervalMap(51, 100, 301, 15000) ); var json = JsonConvert.SerializeObject(tree); var result = await js.InvokeAsync <string>("./External/tree/tree-layout.js", json, thoroughness); if (string.IsNullOrEmpty(result)) { throw new Exception("Failed to render tree: output is empty."); } return(result); }
/// <summary> /// Gets the update form default values. /// </summary> public async Task <UpdateDynamicConfigVM> RequestUpdateAsync() { var config = _cfgService.GetDynamicConfig(); return(_mapper.Map <UpdateDynamicConfigVM>(config)); }