Ejemplo n.º 1
0
 public virtual async Task <bool> IsLinkedAsync(IdentityLinkUserInfo sourceLinkUser, IdentityLinkUserInfo targetLinkUser)
 {
     using (CurrentTenant.Change(null))
     {
         return(await IdentityLinkUserRepository.FindAsync(sourceLinkUser, targetLinkUser) != null);
     }
 }
Ejemplo n.º 2
0
 public virtual async Task <bool> IsLinkedAsync(IdentityLinkUserInfo sourceLinkUser, IdentityLinkUserInfo targetLinkUser, bool includeIndirect = false, CancellationToken cancellationToken = default)
 {
     using (CurrentTenant.Change(null))
     {
         if (includeIndirect)
         {
             return((await GetListAsync(sourceLinkUser, true, cancellationToken: cancellationToken))
                    .Any(x => x.SourceTenantId == targetLinkUser.TenantId && x.SourceUserId == targetLinkUser.UserId ||
                         x.TargetTenantId == targetLinkUser.TenantId && x.TargetUserId == targetLinkUser.UserId));
         }
         return(await IdentityLinkUserRepository.FindAsync(sourceLinkUser, targetLinkUser, cancellationToken) != null);
     }
 }
Ejemplo n.º 3
0
        public virtual async Task UnlinkAsync(IdentityLinkUserInfo sourceLinkUser, IdentityLinkUserInfo targetLinkUser)
        {
            if (!await IsLinkedAsync(sourceLinkUser, targetLinkUser))
            {
                return;
            }

            var linkedUser = await IdentityLinkUserRepository.FindAsync(sourceLinkUser, targetLinkUser);

            if (linkedUser != null)
            {
                await IdentityLinkUserRepository.DeleteAsync(linkedUser);
            }
        }
Ejemplo n.º 4
0
        public virtual async Task UnlinkAsync()
        {
            var john = await UserRepository.GetAsync(TestData.UserJohnId);

            var david = await UserRepository.GetAsync(TestData.UserDavidId);

            (await IdentityLinkUserRepository.FindAsync(new IdentityLinkUserInfo(john.Id, john.TenantId),
                                                        new IdentityLinkUserInfo(david.Id, david.TenantId))).ShouldNotBeNull();

            await IdentityLinkUserManager.UnlinkAsync(new IdentityLinkUserInfo(john.Id, john.TenantId),
                                                      new IdentityLinkUserInfo(david.Id, david.TenantId));

            (await IdentityLinkUserRepository.FindAsync(new IdentityLinkUserInfo(john.Id, john.TenantId),
                                                        new IdentityLinkUserInfo(david.Id, david.TenantId))).ShouldBeNull();
        }
Ejemplo n.º 5
0
    public virtual async Task UnlinkAsync(IdentityLinkUserInfo sourceLinkUser, IdentityLinkUserInfo targetLinkUser, CancellationToken cancellationToken = default)
    {
        using (CurrentTenant.Change(null))
        {
            if (!await IsLinkedAsync(sourceLinkUser, targetLinkUser, cancellationToken: cancellationToken))
            {
                return;
            }

            var linkedUser = await IdentityLinkUserRepository.FindAsync(sourceLinkUser, targetLinkUser, cancellationToken);

            if (linkedUser != null)
            {
                await IdentityLinkUserRepository.DeleteAsync(linkedUser, cancellationToken : cancellationToken);
            }
        }
    }
Ejemplo n.º 6
0
        public virtual async Task LinkAsync()
        {
            var john = await UserRepository.GetAsync(TestData.UserJohnId);

            var neo = await UserRepository.GetAsync(TestData.UserNeoId);

            (await IdentityLinkUserRepository.FindAsync(new IdentityLinkUserInfo(john.Id, john.TenantId),
                                                        new IdentityLinkUserInfo(neo.Id, neo.TenantId))).ShouldBeNull();

            await IdentityLinkUserManager.LinkAsync(new IdentityLinkUserInfo(john.Id, john.TenantId),
                                                    new IdentityLinkUserInfo(neo.Id, neo.TenantId));

            var linkUser = await IdentityLinkUserRepository.FindAsync(new IdentityLinkUserInfo(john.Id, john.TenantId),
                                                                      new IdentityLinkUserInfo(neo.Id, neo.TenantId));

            linkUser.ShouldNotBeNull();
            linkUser.SourceUserId.ShouldBe(john.Id);
            linkUser.SourceTenantId.ShouldBe(john.TenantId);

            linkUser.TargetUserId.ShouldBe(neo.Id);
            linkUser.TargetTenantId.ShouldBe(neo.TenantId);
        }
        public async Task FindAsync()
        {
            var john = await UserRepository.GetAsync(TestData.UserJohnId);

            var david = await UserRepository.GetAsync(TestData.UserDavidId);

            var neo = await UserRepository.GetAsync(TestData.UserNeoId);

            var johnAndDavidLinkUser = await IdentityLinkUserRepository.FindAsync(
                new IdentityLinkUserInfo(john.Id, john.TenantId),
                new IdentityLinkUserInfo(david.Id, david.TenantId));

            johnAndDavidLinkUser.ShouldNotBeNull();
            johnAndDavidLinkUser.SourceUserId.ShouldBe(john.Id);
            johnAndDavidLinkUser.SourceTenantId.ShouldBe(john.TenantId);
            johnAndDavidLinkUser.TargetUserId.ShouldBe(david.Id);
            johnAndDavidLinkUser.TargetTenantId.ShouldBe(david.TenantId);

            (await IdentityLinkUserRepository.FindAsync(
                 new IdentityLinkUserInfo(john.Id, john.TenantId),
                 new IdentityLinkUserInfo(neo.Id, neo.TenantId))).ShouldBeNull();
        }
Ejemplo n.º 8
0
 public virtual async Task <bool> IsLinkedAsync(IdentityLinkUserInfo sourceLinkUser, IdentityLinkUserInfo targetLinkUser)
 {
     return(await IdentityLinkUserRepository.FindAsync(sourceLinkUser, targetLinkUser) != null);
 }