Example #1
0
        public void RemoveAssociation(User user, int externalUserAssociationID, string ip)
        {
            var association = _externalUserAssociationRepository.Get(externalUserAssociationID);

            if (association == null)
            {
                return;
            }
            if (association.UserID != user.UserID)
            {
                throw new Exception(String.Format("Can't delete external user association {0} because it doesn't match UserID {1}.", externalUserAssociationID, user.UserID));
            }
            _externalUserAssociationRepository.Delete(externalUserAssociationID);
            _securityLogService.CreateLogEntry(user, user, ip, String.Format("Issuer: {0}, Provider: {1}, Name: {2}", association.Issuer, association.ProviderKey, association.Name), SecurityLogType.ExternalAssociationRemoved);
        }
        public async Task RemoveAssociation(User user, int externalUserAssociationID, string ip)
        {
            var association = await _externalUserAssociationRepository.Get(externalUserAssociationID);

            if (association == null)
            {
                return;
            }
            if (association.UserID != user.UserID)
            {
                throw new Exception($"Can't delete external user association {externalUserAssociationID} because it doesn't match UserID {user.UserID}.");
            }
            await _externalUserAssociationRepository.Delete(externalUserAssociationID);

            await _securityLogService.CreateLogEntry(user, user, ip, $"Issuer: {association.Issuer}, Provider: {association.ProviderKey}, Name: {association.Name}", SecurityLogType.ExternalAssociationRemoved);
        }