Example #1
0
 public ConfigureAccountLinker(Signature signature, InstanceCrypto instanceCrypto, DbOptionsManager dbOptions, AccountLinkerStorage accountLinkerStorage)
 {
     Signature            = signature;
     InstanceCrypto       = instanceCrypto;
     DbOptions            = dbOptions;
     AccountLinkerStorage = accountLinkerStorage;
 }
 public ConfigureAccountLinker(
     Signature signature,
     InstanceCrypto instanceCrypto,
     AccountLinkerStorage accountLinkerStorage,
     DbContextManager <AccountLinkContext> dbContextManager)
 {
     Signature            = signature;
     InstanceCrypto       = instanceCrypto;
     AccountLinkerStorage = accountLinkerStorage;
     DbContextManager     = dbContextManager;
 }
        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);
        }
        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);
        }
 public IEnumerable <LoginProfile> GetLinkedProfiles(string obj)
 {
     return(AccountLinkerStorage.GetFromCache(obj, GetLinkedProfilesFromDB));
 }