Esempio n. 1
0
        public XmlNode ToXml(XmlDocument d)
        {
            XmlNode toXml = d.CreateElement("wikiFile");

            toXml.Attributes.Append(umbraco.xmlHelper.addAttribute(d, "id", Id.ToString()));
            toXml.Attributes.Append(umbraco.xmlHelper.addAttribute(d, "name", Name));
            toXml.Attributes.Append(umbraco.xmlHelper.addAttribute(d, "created", CreateDate.ToString()));

            toXml.AppendChild(umbraco.xmlHelper.addCDataNode(d, "path", Path));
            toXml.AppendChild(umbraco.xmlHelper.addCDataNode(d, "verified", Verified.ToString()));

            return(toXml);
        }
        /*
         * Execute sqlCommand after setting verified, primaryKeyVal as parameter.
         *
         * Read values returned by command back into fields.
         *
         */
        protected void DoCommand(DataEntryController dec,
                                 SqlCommand sqlCommand,
                                 Verified verified,
                                 int primaryKeyVal)
        {
            // set verified parameter
            sqlCommand.Parameters.AddWithValue("@verified", verified);

            // set primary key parameter
            sqlCommand.Parameters.AddWithValue("@" + dec.PrimaryKeyField, primaryKeyVal);

            // execute
            DoCommand(dec, sqlCommand);
        }
Esempio n. 3
0
        /*
         * Execute sqlCommand setting values passed in ArrayList and
         * verified as parameters.
         *
         * Read values returned by command back into fields.
         *
         */
        protected void DoCommand(DataEntryController dec,
                                 SqlCommand sqlCommand,
                                 Dictionary <string, DataFieldControl> paramFields,
                                 Verified verified)
        {
            // add field parameters
            AddParameters(sqlCommand.Parameters, paramFields);

            // set verified parameter
            sqlCommand.Parameters.AddWithValue("@verified", verified);

            // execute
            DoCommand(dec, sqlCommand);
        }
        /*
         * Execute sqlCommand setting values passed in ArrayList and
         * verified as parameters.
         *
         * Read values returned by command back into fields.
         *
         */
        protected void DoCommand(DataEntryController dec,
                                 SqlCommand sqlCommand,
                                 ArrayList paramFields,
                                 Verified verified)
        {
            // add field parameters
            AddParameters(sqlCommand.Parameters, paramFields);

            // set verified parameter
            sqlCommand.Parameters.AddWithValue("@verified", verified);

            // execute
            DoCommand(dec, sqlCommand);
        }
        /// <summary>
        /// Uploads the card.
        /// </summary>
        /// <param name="frontBase64Encoded">The front base64 encoded.</param>
        /// <param name="backBase64Encoded">The back base64 encoded.</param>
        /// <param name="webhookUrl">The webhook URL.</param>
        /// <param name="casing">The casing.</param>
        /// <param name="sandbox">The sandbox.</param>
        /// <param name="verified">The verified.</param>
        /// <param name="verifiedOnly">The verified only.</param>
        /// <returns></returns>
        /// <exception cref="System.ArgumentNullException">frontBase64Encoded;A front image is required to process a card.</exception>
        public CardReaderResponse UploadCard(
            string frontBase64Encoded,
            string backBase64Encoded,
            string webhookUrl,
            Casing? casing = null,
            SandboxMode? sandbox = null,
            Verified? verified = null,
            bool? verifiedOnly = null)
        {
            if (string.IsNullOrWhiteSpace(frontBase64Encoded)) throw new ArgumentNullException("frontBase64Encoded", "A front image is required to process a card.");

            var request = GetCardReaderRequest(webhookUrl, casing, sandbox, verified, verifiedOnly);
            request.RequestFormat = DataFormat.Json;
            request.AddBody(new { front = frontBase64Encoded, back = backBase64Encoded });
            return Execute<CardReaderResponse>(request);
        }
Esempio n. 6
0
        public override int GetHashCode()
        {
            unchecked {
                int hash = 17;
                hash = hash * 23 + Verified.GetHashCode();
                hash = hash * 23 + Active.GetHashCode();
                hash = hash * 23 + Name.GetHashCode();
                hash = hash * 23 + Email.GetHashCode();
                hash = hash * 23 + Description.GetHashCode();
                hash = hash * 23 + Type.GetHashCode();
                hash = hash * 23 + TaxID.GetHashCode();
                hash = hash * 23 + BankAccount.GetHashCode();
                hash = hash * 23 + FailureCode.GetHashCode();

                return(hash);
            }
        }
Esempio n. 7
0
        public override int GetHashCode()
        {
            unchecked {
                int hash = 17;
                if (Verified != default(bool))
                {
                    hash = hash * 23 + Verified.GetHashCode();
                }
                if (Active != default(bool))
                {
                    hash = hash * 23 + Active.GetHashCode();
                }
                if (Name != default(string))
                {
                    hash = hash * 23 + Name.GetHashCode();
                }
                if (Email != default(string))
                {
                    hash = hash * 23 + Email.GetHashCode();
                }
                if (Description != default(string))
                {
                    hash = hash * 23 + Description.GetHashCode();
                }
                if (Type != default(RecipientType))
                {
                    hash = hash * 23 + Type.GetHashCode();
                }
                if (TaxID != default(string))
                {
                    hash = hash * 23 + TaxID.GetHashCode();
                }
                if (BankAccount != default(BankAccount))
                {
                    hash = hash * 23 + BankAccount.GetHashCode();
                }
                if (FailureCode != default(string))
                {
                    hash = hash * 23 + FailureCode.GetHashCode();
                }

                return(hash);
            }
        }
        /// <summary>
        /// Uploads the card.
        /// </summary>
        /// <param name="front">The front.</param>
        /// <param name="back">The back.</param>
        /// <param name="webhookUrl">The webhook URL.</param>
        /// <param name="casing">The casing.</param>
        /// <param name="sandbox">The sandbox.</param>
        /// <param name="verified">The verified.</param>
        /// <param name="verifiedOnly">The verified only.</param>
        /// <returns></returns>
        /// <exception cref="System.ArgumentNullException">A webhook is required to process a card.</exception>
        public CardReaderResponse UploadCard(
            byte[] front,
            byte[] back,
            string webhookUrl,
            Casing? casing = null,
            SandboxMode? sandbox = null,
            Verified? verified = null,
            bool? verifiedOnly = null)
        {
            if (front == null || front.Length == 0) throw new ArgumentNullException("front", "A front image is required to process a card.");

            var request = GetCardReaderRequest(webhookUrl, casing, sandbox, verified, verifiedOnly);
            request.AddFile("front", front, "front.png|jpg|gif", "image/png|jpg|gif");

            if (back != null && back.Length > 0)
            {
                request.AddFile("back", back, "back.png|jpg|gif", "image/png|jpg|gif");
            }

            return Execute<CardReaderResponse>(request);
        }
 private void RaiseVerifiedEvent()
 {
     Verified?.Invoke(this, EventArgs.Empty);
 }
Esempio n. 10
0
 /// <summary>
 /// Verifies the trial.
 /// </summary>
 public void VerifyTheTrial()
 {
     Verified.Click();
     VerifyComment.SendKeys("Verified by Automated Regression Test");
     SaveVerifyButton.Click();
 }
        /// <summary>
        ///
        /// </summary>
        /// <param name="metadata"></param>
        /// <param name="content"></param>
        /// <returns></returns>
        /// <exception cref="ProtocolInvalidMessageException"></exception>
        /// <exception cref="ProtocolInvalidKeyException"></exception>
        private static SignalServiceSyncMessage CreateSynchronizeMessage(SignalServiceMetadata metadata, SyncMessage content)
        {
            if (content.Sent != null)
            {
                var unidentifiedStatuses             = new Dictionary <SignalServiceAddress, bool>();
                SyncMessage.Types.Sent   sentContent = content.Sent;
                SignalServiceDataMessage dataMessage = CreateSignalServiceMessage(metadata, sentContent.Message);
                SignalServiceAddress?    address     = SignalServiceAddress.IsValidAddress(sentContent.DestinationUuid, sentContent.Destination) ?
                                                       new SignalServiceAddress(UuidUtil.ParseOrNull(sentContent.DestinationUuid), sentContent.Destination) :
                                                       null;

                if (address == null && dataMessage.Group == null)
                {
                    throw new ProtocolInvalidMessageException(new InvalidMessageException("SyncMessage missing both destination and group ID!"), null, 0);
                }

                foreach (var status in sentContent.UnidentifiedStatus)
                {
                    if (SignalServiceAddress.IsValidAddress(status.DestinationUuid, status.Destination))
                    {
                        SignalServiceAddress recipient = new SignalServiceAddress(UuidUtil.ParseOrNull(status.DestinationUuid), status.Destination);
                        unidentifiedStatuses.Add(recipient, status.Unidentified);
                    }
                    else
                    {
                        logger.LogWarning("Encountered an invalid UnidentifiedDeliveryStatus in a SentTranscript! Ignoring.");
                    }
                }

                return(SignalServiceSyncMessage.ForSentTranscript(new SentTranscriptMessage(address !,
                                                                                            (long)sentContent.Timestamp,
                                                                                            CreateSignalServiceMessage(metadata, sentContent.Message),
                                                                                            (long)sentContent.ExpirationStartTimestamp,
                                                                                            unidentifiedStatuses,
                                                                                            sentContent.IsRecipientUpdate)));
            }

            if (content.Request != null)
            {
                return(SignalServiceSyncMessage.ForRequest(new RequestMessage(content.Request)));
            }

            if (content.Read.Count > 0)
            {
                List <ReadMessage> readMessages = new List <ReadMessage>();

                foreach (SyncMessage.Types.Read read in content.Read)
                {
                    if (SignalServiceAddress.IsValidAddress(read.SenderUuid, read.Sender))
                    {
                        SignalServiceAddress address = new SignalServiceAddress(UuidUtil.ParseOrNull(read.SenderUuid), read.Sender);
                        readMessages.Add(new ReadMessage(address, (long)read.Timestamp));
                    }
                    else
                    {
                        logger.LogWarning("Encountered an invalid ReadMessage! Ignoring.");
                    }
                }

                return(SignalServiceSyncMessage.ForRead(readMessages));
            }

            if (content.ViewOnceOpen != null)
            {
                if (SignalServiceAddress.IsValidAddress(content.ViewOnceOpen.SenderUuid, content.ViewOnceOpen.Sender))
                {
                    SignalServiceAddress address   = new SignalServiceAddress(UuidUtil.ParseOrNull(content.ViewOnceOpen.SenderUuid), content.ViewOnceOpen.Sender);
                    ViewOnceOpenMessage  timerRead = new ViewOnceOpenMessage(address, (long)content.ViewOnceOpen.Timestamp);
                    return(SignalServiceSyncMessage.ForViewOnceOpen(timerRead));
                }
                else
                {
                    throw new ProtocolInvalidMessageException(new InvalidMessageException("ViewOnceOpen message has no sender!"), null, 0);
                }
            }

            if (content.Contacts != null)
            {
                AttachmentPointer pointer = content.Contacts.Blob;
                return(SignalServiceSyncMessage.ForContacts(new ContactsMessage(CreateAttachmentPointer(pointer), content.Contacts.Complete)));
            }

            if (content.Groups != null)
            {
                AttachmentPointer pointer = content.Groups.Blob;
                return(SignalServiceSyncMessage.ForGroups(CreateAttachmentPointer(pointer)));
            }

            if (content.Verified != null)
            {
                if (SignalServiceAddress.IsValidAddress(content.Verified.DestinationUuid, content.Verified.Destination))
                {
                    try
                    {
                        Verified             verified    = content.Verified;
                        SignalServiceAddress destination = new SignalServiceAddress(UuidUtil.ParseOrNull(verified.DestinationUuid), verified.Destination);
                        IdentityKey          identityKey = new IdentityKey(verified.IdentityKey.ToByteArray(), 0);

                        VerifiedMessage.VerifiedState verifiedState;

                        if (verified.State == Verified.Types.State.Default)
                        {
                            verifiedState = VerifiedMessage.VerifiedState.Default;
                        }
                        else if (verified.State == Verified.Types.State.Verified)
                        {
                            verifiedState = VerifiedMessage.VerifiedState.Verified;
                        }
                        else if (verified.State == Verified.Types.State.Unverified)
                        {
                            verifiedState = VerifiedMessage.VerifiedState.Unverified;
                        }
                        else
                        {
                            throw new ProtocolInvalidMessageException(new InvalidMessageException($"Unknown state: {(int)verified.State}"),
                                                                      metadata.Sender.GetIdentifier(), metadata.SenderDevice);
                        }

                        return(SignalServiceSyncMessage.ForVerified(new VerifiedMessage(destination, identityKey, verifiedState, Util.CurrentTimeMillis())));
                    }
                    catch (InvalidKeyException ex)
                    {
                        throw new ProtocolInvalidKeyException(ex, metadata.Sender.GetIdentifier(), metadata.SenderDevice);
                    }
                }
                else
                {
                    throw new ProtocolInvalidMessageException(new InvalidMessageException("Verified message has no sender!"), null, 0);
                }
            }

            if (content.StickerPackOperation.Count > 0)
            {
                List <StickerPackOperationMessage> operations = new List <StickerPackOperationMessage>();

                foreach (var operation in content.StickerPackOperation)
                {
                    byte[]? packId  = operation.HasPackId ? operation.PackId.ToByteArray() : null;
                    byte[]? packKey = operation.HasPackKey ? operation.PackKey.ToByteArray() : null;
                    StickerPackOperationMessage.OperationType?type = null;

                    if (operation.HasType)
                    {
                        switch (operation.Type)
                        {
                        case SyncMessage.Types.StickerPackOperation.Types.Type.Install: type = StickerPackOperationMessage.OperationType.Install; break;

                        case SyncMessage.Types.StickerPackOperation.Types.Type.Remove: type = StickerPackOperationMessage.OperationType.Remove; break;
                        }
                    }
                    operations.Add(new StickerPackOperationMessage(packId, packKey, type));
                }

                return(SignalServiceSyncMessage.ForStickerPackOperations(operations));
            }

            if (content.Blocked != null)
            {
                List <string> numbers = content.Blocked.Numbers.ToList();
                List <string> uuids   = content.Blocked.Uuids.ToList();
                List <SignalServiceAddress> addresses = new List <SignalServiceAddress>(numbers.Count + uuids.Count);
                List <byte[]> groupIds = new List <byte[]>(content.Blocked.GroupIds.Count);

                foreach (string e164 in numbers)
                {
                    SignalServiceAddress?address = SignalServiceAddress.FromRaw(null, e164);
                    if (address != null)
                    {
                        addresses.Add(address);
                    }
                }

                foreach (string uuid in uuids)
                {
                    SignalServiceAddress?address = SignalServiceAddress.FromRaw(uuid, null);
                    if (address != null)
                    {
                        addresses.Add(address);
                    }
                }

                foreach (ByteString groupId in content.Blocked.GroupIds)
                {
                    groupIds.Add(groupId.ToByteArray());
                }

                return(SignalServiceSyncMessage.ForBlocked(new BlockedListMessage(addresses, groupIds)));
            }

            if (content.Configuration != null)
            {
                bool?readReceipts = content.Configuration.HasReadReceipts ? content.Configuration.ReadReceipts : (bool?)null;
                bool?unidentifiedDeliveryIndicators = content.Configuration.HasUnidentifiedDeliveryIndicators ? content.Configuration.UnidentifiedDeliveryIndicators : (bool?)null;
                bool?typingIndicators = content.Configuration.HasTypingIndicators ? content.Configuration.TypingIndicators : (bool?)null;
                bool?linkPreviews     = content.Configuration.HasLinkPreviews ? content.Configuration.LinkPreviews : (bool?)null;

                return(SignalServiceSyncMessage.ForConfiguration(new ConfigurationMessage(readReceipts, unidentifiedDeliveryIndicators, typingIndicators, linkPreviews)));
            }

            return(SignalServiceSyncMessage.Empty());
        }
Esempio n. 12
0
        private async Task <TokenResponse> ExternalLogin(GoogleResponse googleResult, string deviceToken,
                                                         OsType osType, string deviceId, string currencyCode)
        {
            User     user = new User();
            Password password;
            var      generatedPassword = googleResult.Sub.ToCharArray().Reverse().ToString();
            var      firstCasePerson   = await _repository
                                         .Filter <User>(x => x.Email == googleResult.Email && x.VerifiedBy == VerifiedBy.Email).FirstOrDefaultAsync();

            var secondCasePerson = await _repository.Filter <User>(x =>
                                                                   x.Email == googleResult.Email && x.VerifiedBy == VerifiedBy.Email).Include(p => p.Passwords).FirstOrDefaultAsync();

            if (firstCasePerson != null && firstCasePerson.IsBlocked || secondCasePerson != null && secondCasePerson.IsBlocked)
            {
                throw new Exception(_optionsBinder.Error().BlockedAccount);
            }
            int      currencyId = 1;
            Currency currency   = _repository.Filter <Currency>(c => c.Code == currencyCode && !c.IsDeleted).FirstOrDefault();

            if (currency != null)
            {
                currencyId = currency.Id;
            }
            if (firstCasePerson == null)
            {
                var photo = await _mediaAccessor.GetPhotoFromSocial(googleResult.Picture);

                user = new User
                {
                    Email          = googleResult.Email,
                    FullName       = $"{googleResult.Given_name} {googleResult.Family_name}",
                    ProfilePhoto   = photo,
                    RoleEnum       = Role.User,
                    OsType         = osType,
                    UserStatusType = UserStatusType.Active,
                    VerifiedBy     = VerifiedBy.Email,
                    DateOfBirth    = null,
                    IsLocal        = false,
                    CurrencyId     = currencyId
                };
                _repository.Create(user);
                password = new Password
                {
                    UserId           = user.Id,
                    LoginProvider    = SocialLoginProvider.Google,
                    UniqueIdentifier = googleResult.Sub,
                    PasswordHash     = Utilities.HashPassword(generatedPassword)
                };
                _repository.Create(password);
                var verified = await _repository.Filter <Verified>(x => x.Email.ToLower() == googleResult.Email.ToLower()).FirstOrDefaultAsync();

                if (verified == null)
                {
                    verified = new Verified
                    {
                        Code         = "0000",
                        Email        = googleResult.Email,
                        IsRegistered = true,
                        VerifiedType = VerifiedType.Verify,
                        VerifiedBy   = VerifiedBy.Email,
                        IsVerified   = true
                    };
                    _repository.Create(verified);
                }
            }
            else if (secondCasePerson != null)
            {
                user = secondCasePerson;
            }
            if (firstCasePerson == null && secondCasePerson == null)
            {
                foreach (SubscriptionsType variable in Enum.GetValues(typeof(SubscriptionsType)))
                {
                    _repository.Create(new PersonSetting
                    {
                        UserId            = user.Id,
                        SubscriptionsType = variable
                    });
                }
                _repository.Create(new PersonOtherSetting
                {
                    UserId   = user.Id,
                    AreaUnit = AreaUnit.SquareMeter,
                    Language = Language.English
                });
            }
            await _repository.SaveChangesAsync();

            if (user.VerifiedBy == VerifiedBy.Email)
            {
                var html = Utilities.NewUserEmailStyle(user.Email);
                Utilities.SendEmail(user.Email, "Baitkm", html);
            }
            return(await Token(new SocialTokenViewModel
            {
                DeviceToken = deviceToken,
                DeviceId = deviceId,
                OsType = osType,
                Password = generatedPassword,
                Provider = SocialLoginProvider.Google,
                SocialId = googleResult.Sub,
                Email = user.Email,
                Id = user.Id
            }));
        }
Esempio n. 13
0
        private SignalServiceSyncMessage CreateSynchronizeMessage(Metadata metadata, SyncMessage content)
        {
            if (content.SentOneofCase == SyncMessage.SentOneofOneofCase.Sent)
            {
                SyncMessage.Types.Sent sentContent = content.Sent;
                var unidentifiedStatuses           = new Dictionary <string, bool>();

                foreach (var status in sentContent.UnidentifiedStatus)
                {
                    unidentifiedStatuses[status.Destination] = status.Unidentified;
                }

                return(SignalServiceSyncMessage.ForSentTranscript(new SentTranscriptMessage(sentContent.Destination,
                                                                                            (long)sentContent.Timestamp,
                                                                                            CreateSignalServiceMessage(metadata, sentContent.Message),
                                                                                            (long)sentContent.ExpirationStartTimestamp,
                                                                                            unidentifiedStatuses)));
            }

            if (content.RequestOneofCase == SyncMessage.RequestOneofOneofCase.Request)
            {
                return(SignalServiceSyncMessage.ForRequest(new RequestMessage(content.Request)));
            }

            if (content.Read.Count > 0)
            {
                List <ReadMessage> readMessages = new List <ReadMessage>();

                foreach (SyncMessage.Types.Read read in content.Read)
                {
                    readMessages.Add(new ReadMessage(read.Sender, (long)read.Timestamp));
                }

                return(SignalServiceSyncMessage.ForRead(readMessages));
            }

            if (content.ContactsOneofCase == SyncMessage.ContactsOneofOneofCase.Contacts)
            {
                AttachmentPointer pointer = content.Contacts.Blob;
                return(SignalServiceSyncMessage.ForContacts(new ContactsMessage(CreateAttachmentPointer(pointer), content.Contacts.Complete)));
            }

            if (content.GroupsOneofCase == SyncMessage.GroupsOneofOneofCase.Groups)
            {
                AttachmentPointer pointer = content.Groups.Blob;
                return(SignalServiceSyncMessage.ForGroups(CreateAttachmentPointer(pointer)));
            }

            if (content.VerifiedOneofCase == SyncMessage.VerifiedOneofOneofCase.Verified)
            {
                try
                {
                    Verified    verified    = content.Verified;
                    string      destination = verified.Destination;
                    IdentityKey identityKey = new IdentityKey(verified.IdentityKey.ToByteArray(), 0);

                    VerifiedMessage.VerifiedState verifiedState;

                    if (verified.State == Verified.Types.State.Default)
                    {
                        verifiedState = VerifiedMessage.VerifiedState.Default;
                    }
                    else if (verified.State == Verified.Types.State.Verified)
                    {
                        verifiedState = VerifiedMessage.VerifiedState.Verified;
                    }
                    else if (verified.State == Verified.Types.State.Unverified)
                    {
                        verifiedState = VerifiedMessage.VerifiedState.Unverified;
                    }
                    else
                    {
                        throw new InvalidMessageException("Unknown state: " + verified.State);
                    }

                    return(SignalServiceSyncMessage.ForVerified(new VerifiedMessage(destination, identityKey, verifiedState, Util.CurrentTimeMillis())));
                }
                catch (InvalidKeyException e)
                {
                    throw new InvalidMessageException(e);
                }
            }

            if (content.BlockedOneofCase == SyncMessage.BlockedOneofOneofCase.Blocked)
            {
                List <string> blockedNumbers = new List <string>(content.Blocked.Numbers.Count);
                foreach (var blocked in content.Blocked.Numbers)
                {
                    blockedNumbers.Add(blocked);
                }
                return(SignalServiceSyncMessage.ForBlocked(new BlockedListMessage(blockedNumbers, content.Blocked.GroupIds.Select(gid => gid.ToByteArray()).ToList())));
            }

            if (content.VerifiedOneofCase == SyncMessage.VerifiedOneofOneofCase.Verified)
            {
                try
                {
                    Verified    verified    = content.Verified;
                    string      destination = verified.Destination;
                    IdentityKey identityKey = new IdentityKey(verified.IdentityKey.ToByteArray(), 0);

                    VerifiedMessage.VerifiedState verifiedState;

                    if (verified.State == Verified.Types.State.Default)
                    {
                        verifiedState = VerifiedMessage.VerifiedState.Default;
                    }
                    else if (verified.State == Verified.Types.State.Verified)
                    {
                        verifiedState = VerifiedMessage.VerifiedState.Verified;
                    }
                    else if (verified.State == Verified.Types.State.Unverified)
                    {
                        verifiedState = VerifiedMessage.VerifiedState.Unverified;
                    }
                    else
                    {
                        throw new ProtocolInvalidMessageException(new InvalidMessageException("Unknown state: " + verified.State),
                                                                  metadata.Sender, metadata.SenderDevice);
                    }
                    return(SignalServiceSyncMessage.ForVerified(new VerifiedMessage(destination, identityKey, verifiedState, Util.CurrentTimeMillis())));
                }
                catch (InvalidKeyException e)
                {
                    throw new ProtocolInvalidKeyException(e, metadata.Sender, metadata.SenderDevice);
                }
            }
            return(SignalServiceSyncMessage.Empty());
        }
 private void InvokeVerified(SysCheckType checkType, bool verified)
 {
     Verified?.Invoke(_type, checkType, verified);
 }
Esempio n. 15
0
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         // Suitable nullity checks etc, of course :)
         if (ProfileMedium != null)
         {
             hashCode = hashCode * 59 + ProfileMedium.GetHashCode();
         }
         if (CoverPhoto != null)
         {
             hashCode = hashCode * 59 + CoverPhoto.GetHashCode();
         }
         if (CoverPhotoSmall != null)
         {
             hashCode = hashCode * 59 + CoverPhotoSmall.GetHashCode();
         }
         if (SportType != null)
         {
             hashCode = hashCode * 59 + SportType.GetHashCode();
         }
         if (ActivityTypes != null)
         {
             hashCode = hashCode * 59 + ActivityTypes.GetHashCode();
         }
         if (City != null)
         {
             hashCode = hashCode * 59 + City.GetHashCode();
         }
         if (State != null)
         {
             hashCode = hashCode * 59 + State.GetHashCode();
         }
         if (Country != null)
         {
             hashCode = hashCode * 59 + Country.GetHashCode();
         }
         if (_Private != null)
         {
             hashCode = hashCode * 59 + _Private.GetHashCode();
         }
         if (MemberCount != null)
         {
             hashCode = hashCode * 59 + MemberCount.GetHashCode();
         }
         if (Featured != null)
         {
             hashCode = hashCode * 59 + Featured.GetHashCode();
         }
         if (Verified != null)
         {
             hashCode = hashCode * 59 + Verified.GetHashCode();
         }
         if (Url != null)
         {
             hashCode = hashCode * 59 + Url.GetHashCode();
         }
         return(hashCode);
     }
 }
Esempio n. 16
0
        /// <summary>
        /// Returns true if SummaryClub instances are equal
        /// </summary>
        /// <param name="other">Instance of SummaryClub to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(SummaryClub other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     ProfileMedium == other.ProfileMedium ||
                     ProfileMedium != null &&
                     ProfileMedium.Equals(other.ProfileMedium)
                     ) &&
                 (
                     CoverPhoto == other.CoverPhoto ||
                     CoverPhoto != null &&
                     CoverPhoto.Equals(other.CoverPhoto)
                 ) &&
                 (
                     CoverPhotoSmall == other.CoverPhotoSmall ||
                     CoverPhotoSmall != null &&
                     CoverPhotoSmall.Equals(other.CoverPhotoSmall)
                 ) &&
                 (
                     SportType == other.SportType ||
                     SportType != null &&
                     SportType.Equals(other.SportType)
                 ) &&
                 (
                     ActivityTypes == other.ActivityTypes ||
                     ActivityTypes != null &&
                     ActivityTypes.SequenceEqual(other.ActivityTypes)
                 ) &&
                 (
                     City == other.City ||
                     City != null &&
                     City.Equals(other.City)
                 ) &&
                 (
                     State == other.State ||
                     State != null &&
                     State.Equals(other.State)
                 ) &&
                 (
                     Country == other.Country ||
                     Country != null &&
                     Country.Equals(other.Country)
                 ) &&
                 (
                     _Private == other._Private ||
                     _Private != null &&
                     _Private.Equals(other._Private)
                 ) &&
                 (
                     MemberCount == other.MemberCount ||
                     MemberCount != null &&
                     MemberCount.Equals(other.MemberCount)
                 ) &&
                 (
                     Featured == other.Featured ||
                     Featured != null &&
                     Featured.Equals(other.Featured)
                 ) &&
                 (
                     Verified == other.Verified ||
                     Verified != null &&
                     Verified.Equals(other.Verified)
                 ) &&
                 (
                     Url == other.Url ||
                     Url != null &&
                     Url.Equals(other.Url)
                 ));
        }
Esempio n. 17
0
        private void WriteContactDetails(DeviceContact contact)
        {
            ContactDetails contactDetails = new ContactDetails();

            if (contact.Address.Uuid.HasValue)
            {
                contactDetails.Uuid = contact.Address.Uuid.Value.ToString();
            }

            if (contact.Address.GetNumber() != null)
            {
                contactDetails.Number = contact.Address.GetNumber();
            }

            if (contact.Name != null)
            {
                contactDetails.Name = contact.Name;
            }

            if (contact.Avatar != null)
            {
                ContactDetails.Types.Avatar avatarBuilder = new ContactDetails.Types.Avatar();
                avatarBuilder.ContentType = contact.Avatar.ContentType;
                avatarBuilder.Length      = (uint)contact.Avatar.Length;
                contactDetails.Avatar     = avatarBuilder;
            }

            if (contact.Color != null)
            {
                contactDetails.Color = contact.Color;
            }

            if (contact.Verified != null)
            {
                Verified.Types.State state;

                switch (contact.Verified.Verified)
                {
                case VerifiedMessage.VerifiedState.Verified: state = Verified.Types.State.Verified; break;

                case VerifiedMessage.VerifiedState.Unverified: state = Verified.Types.State.Unverified; break;

                default: state = Verified.Types.State.Default; break;
                }

                Verified verifiedBuilder = new Verified()
                {
                    IdentityKey = ByteString.CopyFrom(contact.Verified.IdentityKey.serialize()),
                    State       = state
                };

                if (contact.Verified.Destination.Uuid.HasValue)
                {
                    verifiedBuilder.DestinationUuid = contact.Verified.Destination.Uuid.Value.ToString();
                }

                if (contact.Verified.Destination.GetNumber() != null)
                {
                    verifiedBuilder.DestinationE164 = contact.Verified.Destination.GetNumber();
                }

                contactDetails.Verified = verifiedBuilder;
            }

            if (contact.ProfileKey != null)
            {
                contactDetails.ProfileKey = ByteString.CopyFrom(contact.ProfileKey);
            }

            if (contact.ExpirationTimer.HasValue)
            {
                contactDetails.ExpireTimer = contact.ExpirationTimer.Value;
            }

            contactDetails.Blocked = contact.Blocked;

            byte[] serializedContactDetails = contactDetails.ToByteArray();

            WriteVarint32(serializedContactDetails.Length);
            output.Write(serializedContactDetails, 0, serializedContactDetails.Length);
        }
Esempio n. 18
0
        public async Task <TokenResponse> AppleLogin(AppleSignInRequestModel model,
                                                     string email, string appleId, string deviceToken, Language language, string deviceId, string currencyCode)
        {
            User     user = new User();
            Password password;
            string   generatedPassword = email.ToCharArray().Reverse().ToString();
            var      firstCasePerson   = await _repository
                                         .Filter <User>(x => x.Email == email && x.VerifiedBy == VerifiedBy.Email).FirstOrDefaultAsync();

            var secondCasePerson = await _repository.Filter <User>(x =>
                                                                   x.Email == email && x.VerifiedBy == VerifiedBy.Email).Include(p => p.Passwords).FirstOrDefaultAsync();

            if (firstCasePerson != null && firstCasePerson.IsBlocked || secondCasePerson != null && secondCasePerson.IsBlocked)
            {
                throw new Exception(_optionsBinder.Error().BlockedAccount);
            }
            int      currencyId = 1;
            Currency currency   = _repository.Filter <Currency>(c => c.Code == currencyCode && !c.IsDeleted).FirstOrDefault();

            if (currency != null)
            {
                currencyId = currency.Id;
            }
            if (firstCasePerson == null)
            {
                generatedPassword = email.ToCharArray().Reverse().ToString();
                user = new User
                {
                    Email          = email,
                    FullName       = model.FullName,
                    ProfilePhoto   = null,
                    RoleEnum       = Role.User,
                    VerifiedBy     = VerifiedBy.Email,
                    OsType         = OsType.Ios,
                    UserStatusType = UserStatusType.Active,
                    DateOfBirth    = null,
                    IsLocal        = false,
                    CurrencyId     = currencyId
                };
                _repository.Create(user);
                password = new Password
                {
                    UserId           = user.Id,
                    LoginProvider    = SocialLoginProvider.Apple,
                    UniqueIdentifier = appleId,
                    PasswordHash     = Utilities.HashPassword(generatedPassword)
                };
                _repository.Create(password);
                var verified = await _repository.Filter <Verified>(x => x.Email.ToLower() == email.ToLower()).FirstOrDefaultAsync();

                if (verified == null)
                {
                    verified = new Verified
                    {
                        Code         = "0000",
                        Email        = email,
                        IsRegistered = true,
                        VerifiedType = VerifiedType.Verify,
                        VerifiedBy   = VerifiedBy.Email,
                        IsVerified   = true
                    };
                }
                _repository.Create(verified);
            }
            else if (secondCasePerson != null)
            {
                user = secondCasePerson;
            }
            if ((firstCasePerson == null) && (secondCasePerson == null))
            {
                foreach (SubscriptionsType variable in Enum.GetValues(typeof(SubscriptionsType)))
                {
                    _repository.Create(new PersonSetting
                    {
                        UserId            = user.Id,
                        SubscriptionsType = variable
                    });
                }
                _repository.Create(new PersonOtherSetting
                {
                    UserId   = user.Id,
                    AreaUnit = AreaUnit.SquareMeter,
                    Language = Language.English
                });
            }
            await _repository.SaveChangesAsync();

            return(await Token(new SocialTokenViewModel
            {
                DeviceToken = deviceToken,
                DeviceId = deviceId,
                OsType = OsType.Ios,
                Password = generatedPassword,
                Provider = SocialLoginProvider.Apple,
                SocialId = appleId,
                Email = user.Email,
                Id = user.Id
            }));
        }
Esempio n. 19
0
 /// <summary>
 /// Called after a player has been verified.
 /// </summary>
 /// <param name="ev">The <see cref="VerifiedEventArgs"/> instance.</param>
 public static void OnVerified(VerifiedEventArgs ev) => Verified.InvokeSafely(ev);
        /// <summary>
        /// Gets the card reader request.
        /// </summary>
        /// <param name="webhookUrl">The webhook URL.</param>
        /// <param name="casing">The casing.</param>
        /// <param name="sandbox">The sandbox.</param>
        /// <param name="verified">The verified.</param>
        /// <param name="verifiedOnly">The verified only.</param>
        /// <returns></returns>
        /// <exception cref="System.ArgumentNullException">A webhook is required to process a card.</exception>
        private RestRequest GetCardReaderRequest(
            string webhookUrl,
            Casing? casing = null,
            SandboxMode? sandbox = null,
            Verified? verified = null,
            bool? verifiedOnly = null)
        {
            if (string.IsNullOrWhiteSpace(webhookUrl)) throw new ArgumentNullException("webhookUrl", "A webhook is required to process a card.");

            var request = new RestRequest("/cardReader.json", Method.POST);
            request.AddQueryParameter("webhookUrl", webhookUrl);

            if (casing.HasValue)
            {
                request.AddQueryParameter("casing", casing.Value.ToString());
            }

            if (sandbox.HasValue)
            {
                request.AddQueryParameter("sandbox", sandbox.Value.ToString());
            }

            if (verified.HasValue)
            {
                request.AddQueryParameter("verified", verified.Value.ToString());
            }

            if (verifiedOnly.HasValue && verifiedOnly.Value)
            {
                request.AddQueryParameter("returnedData", "verifiedOnly");
            }

            return request;
        }