// Create public async Task InsertItem(LocalStorageModel obj) { IMongoCollection <LocalStorageModel> collection = database.GetCollection <LocalStorageModel>(tableName); var filter = Builders <LocalStorageModel> .Filter.Eq("Key", obj.Key); if (await collection.FindAsync <LocalStorageModel>(filter) != null) { await collection.InsertOneAsync(obj); } }
public override async Task <AuthenticationState> GetAuthenticationStateAsync() { LocalStorageModel storageModel = await serverHandler.StorageService.LoadItemByKey("authToken"); string savedToken = storageModel?.Value as string ?? ""; if (string.IsNullOrWhiteSpace(savedToken)) { return(new AuthenticationState(new ClaimsPrincipal(new ClaimsIdentity()))); } return(new AuthenticationState(new ClaimsPrincipal(new ClaimsIdentity(ParseClaimsFromJwt(savedToken), "jwt")))); }