public async Task <AuthStorage> GetAuthStorageAsync(string id) { var filter = new BsonDocument("_id", id); var session = await AuthStorages.Find(filter) .FirstOrDefaultAsync(); return(session); }
public async Task СreateOrUpdateAuthStorageAsync(string id, string acessToken, string refresh) { var authStorage = new AuthStorage() { UserId = id, AcessToken = acessToken, RefreshToken = refresh }; var filter = new BsonDocument("_id", id); var user = await AuthStorages.Find(filter) .FirstOrDefaultAsync(); if (user != null) { await UpdateAuthStorageAsync(id, acessToken, refresh); return; } await AuthStorages.InsertOneAsync(authStorage); }