예제 #1
0
 public ConfigureAccountLinker(Signature signature, InstanceCrypto instanceCrypto, DbOptionsManager dbOptions, AccountLinkerStorage accountLinkerStorage)
 {
     Signature            = signature;
     InstanceCrypto       = instanceCrypto;
     DbOptions            = dbOptions;
     AccountLinkerStorage = accountLinkerStorage;
 }
예제 #2
0
 public ConfigureAccountLinker(
     Signature signature,
     InstanceCrypto instanceCrypto,
     AccountLinkerStorage accountLinkerStorage,
     DbContextManager <AccountLinkContext> dbContextManager)
 {
     Signature            = signature;
     InstanceCrypto       = instanceCrypto;
     AccountLinkerStorage = accountLinkerStorage;
     DbContextManager     = dbContextManager;
 }
예제 #3
0
        public void AddLink(string obj, LoginProfile profile)
        {
            var accountLink = new AccountLinks
            {
                Id       = obj,
                UId      = profile.HashId,
                Provider = profile.Provider,
                Profile  = profile.ToSerializedString(),
                Linked   = DateTime.UtcNow
            };

            AccountLinkContext.AddOrUpdate(r => r.AccountLinks, accountLink);
            AccountLinkContext.SaveChanges();

            AccountLinkerStorage.RemoveFromCache(obj);
        }
예제 #4
0
        public void RemoveProvider(string obj, string provider = null, string hashId = null)
        {
            using var tr = AccountLinkContext.Database.BeginTransaction();

            var accountLinkQuery = AccountLinks
                                   .Where(r => r.Id == obj);

            if (!string.IsNullOrEmpty(provider))
            {
                accountLinkQuery = accountLinkQuery.Where(r => r.Provider == provider);
            }
            if (!string.IsNullOrEmpty(hashId))
            {
                accountLinkQuery = accountLinkQuery.Where(r => r.UId == hashId);
            }

            var accountLink = accountLinkQuery.FirstOrDefault();

            AccountLinks.Remove(accountLink);

            tr.Commit();
            AccountLinkerStorage.RemoveFromCache(obj);
        }
예제 #5
0
 public IEnumerable <LoginProfile> GetLinkedProfiles(string obj)
 {
     return(AccountLinkerStorage.GetFromCache(obj, GetLinkedProfilesFromDB));
 }