Exemplo n.º 1
0
        public async Task <IdentityResult> InsertIdentityResource(
            IdentityResource model,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            cancellationToken.ThrowIfCancellationRequested();
            ThrowIfDisposed();
            model.ThrowIfNull(nameof(model));
            try
            {
                var dto    = model.ToNeo4jEntity();
                var result = await CreateIdentityResourceAsync(dto);

                if (!result.Succeeded)
                {
                    return(result);
                }
                foreach (var claim in model.UserClaims)
                {
                    var dtoClaim = new Neo4jIdentityServer4IdentityClaim()
                    {
                        Type = claim
                    };
                    result = await AddIdentityClaimAsync(dto, dtoClaim);

                    if (!result.Succeeded)
                    {
                        return(result);
                    }
                }

                return(IdentityResult.Success);
            }
            catch (ClientException ex)
            {
                return(ex.ToIdentityResult());
            }
        }