public async Task <User> GetAsync(Guid id, bool refreshCache, CancellationToken cancellationToken = default) { var cacheKey = $"{CacheKeyPrefix}/{id}"; var cacheValue = await _cache.GetAsync(cacheKey, cancellationToken); if (refreshCache || cacheValue == null) { await _userDomainEntity .WithOptions(x => x.AsNoTracking = true) .GetAsync(id, cancellationToken); var user = _userDomainEntity.Entity; var cacheEntryOptions = new DistributedCacheEntryOptions() .SetSlidingExpiration(TimeSpan.FromMinutes(10)); await _cache.SetAsync(cacheKey, Encode(user), cacheEntryOptions, cancellationToken); return(user); } else { return(Decode(cacheValue)); } }
public async Task <Unit> Handle(SyncRolesToAuth0UserMessage request, CancellationToken cancellationToken) { await _userDomainEntity .WithOptions(x => x.AsNoTracking = true) .GetAsync(request.Data.Id, cancellationToken); await _auth0UserManagementClient.SyncRolesToAuth0Async(_userDomainEntity.Entity, cancellationToken); return(Unit.Value); }
public async Task <Unit> Handle(CreateAuth0UserMessage request, CancellationToken cancellationToken) { await _userDomainEntity .WithOptions(x => x.AsNoTracking = true) .GetAsync(request.Data.Id, cancellationToken); await _auth0UserManagementClient.CreateAsync(_userDomainEntity.Entity, cancellationToken); // TODO: save external id to user table var changePasswordUrl = await _auth0UserManagementClient.GetChangePasswordUrl(_userDomainEntity.Entity, cancellationToken); // TODO: Send invitation email with changePasswordUrl return(Unit.Value); }