public async Task <User> GetOrCreateUser(string newName = null) { var name = newName ?? CurrentUser.Name; CurrentUser = await _apiService.GetUser(name); return(CurrentUser); }
public override async Task <AuthenticationState> GetAuthenticationStateAsync() { var identity = new ClaimsIdentity(); var currentUser = _dataService.CurrentUser; if (currentUser == null || !currentUser.IsAuthenticated) { _dataService.CurrentUser = await _beamApi.GetUser(); currentUser = _dataService.CurrentUser; } if (currentUser.IsAuthenticated) { var claims = new[] { new Claim(ClaimTypes.Name, _dataService.CurrentUser.Name) }.Concat(_dataService.CurrentUser.Claims.Select(c => new Claim(c.Key, c.Value))); identity = new ClaimsIdentity(claims, "Server authentication"); } return(new AuthenticationState(new ClaimsPrincipal(identity))); }