Пример #1
0
        public virtual async Task SeedAsync(
            string providerName,
            string providerKey,
            Dictionary <string, string> permissions,
            Guid?tenantId = null)
        {
            foreach (var permission in permissions)
            {
                var permissionGrant = await PermissionGrantRepository.FindAsync(permission.Key, providerName, providerKey);

                if (permissionGrant != null)
                {
                    if (permissionGrant.ProviderScope == permission.Value)
                    {
                        continue;
                    }
                    permissionGrant.ProviderScope = permission.Value;
                    await PermissionGrantRepository.UpdateAsync(permissionGrant);
                }

                await PermissionGrantRepository.InsertAsync(
                    new PermissionGrant (
                        GuidGenerator.Create(),
                        permission.Key,
                        providerName,
                        permission.Value,
                        providerKey,
                        tenantId
                        )
                    );
            }
        }
        protected virtual async Task GrantAsync(string permissionName, string providerName, string providerScope, string providerKey)
        {
            var permissionGrant = await PermissionGrantRepository.FindAsync(permissionName, providerName, providerKey);

            if (permissionGrant != null)
            {
                if (permissionGrant.ProviderScope == providerScope)
                {
                    return;
                }
                permissionGrant.ProviderScope = providerScope;
                await PermissionGrantRepository.UpdateAsync(permissionGrant);
            }

            await PermissionGrantRepository.InsertAsync(
                new PermissionGrant (
                    GuidGenerator.Create(),
                    permissionName,
                    providerName,
                    providerScope,
                    providerKey,
                    CurrentTenant.Id
                    )
                );
        }
Пример #3
0
        public virtual async Task <PermissionGrant> UpdateProviderKeyAsync(PermissionGrant permissionGrant, string providerKey)
        {
            using (CurrentTenant.Change(permissionGrant.TenantId))
            {
                //Invalidating the cache for the old key
                await Cache.RemoveAsync(
                    PermissionGrantCacheItem.CalculateCacheKey(
                        permissionGrant.Name,
                        permissionGrant.ProviderName,
                        permissionGrant.ProviderKey
                        )
                    );
            }

            permissionGrant.ProviderKey = providerKey;
            return(await PermissionGrantRepository.UpdateAsync(permissionGrant));
        }
Пример #4
0
 public virtual async Task <PermissionGrant> UpdateProviderKeyAsync(PermissionGrant permissionGrant, string providerKey)
 {
     permissionGrant.ProviderKey = providerKey;
     return(await PermissionGrantRepository.UpdateAsync(permissionGrant));
 }
Пример #5
0
 public async Task <PermissionGrant> UpdateProviderKeyAsync(PermissionGrant permissionGrant, string providerKey)
 {
     permissionGrant.ProviderKey = providerKey;
     return(await PermissionGrantRepository.UpdateAsync(permissionGrant).ConfigureAwait(false));
 }