示例#1
0
        public void SendUpdateNewEmailCode(Guid accountId, string emailAddress)
        {
            var dac     = new MerchantAccountDAC();
            var account = dac.GetById(accountId);

            if (account.Email == emailAddress)
            {
                throw new CommonException(ReasonCode.ORIGIN_NEW_EMAIL_SAME, Resources.新邮箱不能和原来的邮箱一致);
            }

            var accountByEmail = dac.GetByEmail(emailAddress);

            if (accountByEmail != null && accountByEmail.Id != accountId)
            {
                throw new CommonException(ReasonCode.EMAIL_BINDBYOTHER, Resources.此邮箱已经绑定到其他邮箱);
            }

            string subject = Resources.验证码邮箱标题;

            SecurityVerify.SendCode(new UpdateEmailNewVerifier(), SystemPlatform.FiiiPOS, accountId.ToString(), emailAddress, subject);
            var model = SecurityVerify.GetModel <FiiiPosUpdateEmailVerify>(new CustomVerifier("UpdateEmail"), SystemPlatform.FiiiPOS, accountId.ToString());

            model.NewEmail = emailAddress;
            SecurityVerify.SetModel(new CustomVerifier("UpdateEmail"), SystemPlatform.FiiiPOS, accountId.ToString(), model);
        }
示例#2
0
        public void VerifyModifyCellphoneCombine(Guid accountId, string smsCode, string googleCode)
        {
            MerchantAccount merchant = new MerchantAccountDAC().GetById(accountId);

            if (merchant == null)
            {
                throw new CommonException(ReasonCode.ACCOUNT_NOT_EXISTS, Resources.用户不存在);
            }
            List <CombinedVerifyOption> options = new List <CombinedVerifyOption>
            {
                new CombinedVerifyOption {
                    AuthType = (byte)ValidationFlag.Cellphone, Code = smsCode
                },
                new CombinedVerifyOption {
                    AuthType = (byte)ValidationFlag.GooogleAuthenticator, Code = googleCode
                }
            };
            UserSecrets userSecrets = new UserSecrets
            {
                ValidationFlag      = merchant.ValidationFlag,
                GoogleAuthSecretKey = merchant.AuthSecretKey
            };

            SecurityVerify.CombinedVerify(SystemPlatform.FiiiPOS, accountId.ToString(), userSecrets, options);

            var model = SecurityVerify.GetModel <ModifyCellphoneVerify>(new CustomVerifier("ModifyCellphone"), SystemPlatform.FiiiPOS, accountId.ToString());

            model.CombinedVerified = true;
            SecurityVerify.SetModel(new CustomVerifier("ModifyCellphone"), SystemPlatform.FiiiPOS, accountId.ToString(), model);
        }
        public void VerifyWithdrawCombine(Guid accountId, string smsCode, string googleCode, string divisionCode)
        {
            UserAccount user = new UserAccountDAC().GetById(accountId);
            List <CombinedVerifyOption> options = new List <CombinedVerifyOption>
            {
                new CombinedVerifyOption {
                    AuthType = (byte)ValidationFlag.Cellphone, Code = smsCode
                },
                new CombinedVerifyOption {
                    AuthType = (byte)ValidationFlag.GooogleAuthenticator, Code = googleCode
                }
            };
            UserSecrets userSecrets = new UserSecrets
            {
                ValidationFlag      = user.ValidationFlag,
                GoogleAuthSecretKey = user.AuthSecretKey
            };

            SecurityVerify.CombinedVerify(SystemPlatform.FiiiPay, user.Id.ToString(), userSecrets, options, divisionCode);

            var model = SecurityVerify.GetModel <WithdrawVerify>(new CustomVerifier("UserWithdraw"), SystemPlatform.FiiiPay, user.Id.ToString());

            model.CombinedVerified = true;
            SecurityVerify.SetModel(new CustomVerifier("UserWithdraw"), SystemPlatform.FiiiPay, user.Id.ToString(), model);
        }
示例#4
0
        public void VerifyCloseCombine(Guid merchantId, string smsCode, string googleCode)
        {
            var merchant = new MerchantAccountDAC().GetById(merchantId);
            List <CombinedVerifyOption> options = new List <CombinedVerifyOption>
            {
                new CombinedVerifyOption {
                    AuthType = (byte)ValidationFlag.Cellphone, Code = smsCode
                },
                new CombinedVerifyOption {
                    AuthType = (byte)ValidationFlag.GooogleAuthenticator, Code = googleCode
                }
            };
            UserSecrets userSecrets = new UserSecrets
            {
                ValidationFlag      = merchant.ValidationFlag,
                GoogleAuthSecretKey = merchant.AuthSecretKey
            };

            SecurityVerify.CombinedVerify(SystemPlatform.FiiiPOS, merchant.Id.ToString(), userSecrets, options, null);

            var model = SecurityVerify.GetModel <CloseGoogleAuth>(new CustomVerifier("CloseGoogleAuth"), SystemPlatform.FiiiPOS, merchant.Id.ToString());

            model.CombinedVerified = true;
            SecurityVerify.SetModel(new CustomVerifier("CloseGoogleAuth"), SystemPlatform.FiiiPOS, merchant.Id.ToString(), model);
        }
示例#5
0
        public void VerifyUpdateEmailPin(UserAccount user, string pin)
        {
            SecurityVerify.Verify(new PinVerifier(), SystemPlatform.FiiiPay, user.Id.ToString(), user.Pin, pin);
            var model = SecurityVerify.GetModel <UpdateEmailVerify>(new CustomVerifier("UpdateEmail"), SystemPlatform.FiiiPay, user.Id.ToString());

            model.PinVerified = true;
            SecurityVerify.SetModel(new CustomVerifier("UpdateEmail"), SystemPlatform.FiiiPay, user.Id.ToString(), model);
        }
示例#6
0
        public void VerifyNewEmail(Guid accountId, string code)
        {
            SecurityVerify.Verify(new UpdateEmailNewVerifier(), SystemPlatform.FiiiPOS, accountId.ToString(), code);
            var model = SecurityVerify.GetModel <FiiiPosUpdateEmailVerify>(new CustomVerifier("UpdateEmail"), SystemPlatform.FiiiPOS, accountId.ToString());

            model.NewEmailVerified = true;
            SecurityVerify.SetModel(new CustomVerifier("UpdateEmail"), SystemPlatform.FiiiPOS, accountId.ToString(), model);
        }
示例#7
0
        public void VerifyModifyCellphoneSMS(Guid accountId, string smsCode)
        {
            SecurityVerify.Verify(new ModifyCellphoneVerifier(), SystemPlatform.FiiiPOS, accountId.ToString(), smsCode, true);
            var model = SecurityVerify.GetModel <ModifyCellphoneVerify>(new CustomVerifier("ModifyCellphone"), SystemPlatform.FiiiPOS, accountId.ToString());

            model.NewCellphoneVerified = true;
            SecurityVerify.SetModel(new CustomVerifier("ModifyCellphone"), SystemPlatform.FiiiPOS, accountId.ToString(), model);
        }
示例#8
0
        /// <summary>
        /// 验证新邮箱
        /// </summary>
        /// <param name="user"></param>
        /// <param name="email"></param>
        /// <param name="code"></param>
        public void VerifyNewEmail(UserAccount user, string email, string code)
        {
            SecurityVerify.Verify(new UpdateEmailNewVerifier(), SystemPlatform.FiiiPay, user.Id.ToString(), code);
            var model = SecurityVerify.GetModel <UpdateEmailVerify>(new CustomVerifier("UpdateEmail"), SystemPlatform.FiiiPay, user.Id.ToString());

            model.NewEmailVerified = true;
            SecurityVerify.SetModel(new CustomVerifier("UpdateEmail"), SystemPlatform.FiiiPay, user.Id.ToString(), model);
        }
示例#9
0
        public void VerifyBindGoogleAuth(Guid accountId, string secretKey, string code)
        {
            SecurityVerify.Verify(new GoogleVerifier(), SystemPlatform.FiiiPOS, accountId.ToString(), secretKey, code);
            var model = SecurityVerify.GetModel <BindGoogleAuth>(new CustomVerifier("BindGoogleAuth"), SystemPlatform.FiiiPOS, accountId.ToString());

            model.GoogleVerified = true;
            SecurityVerify.SetModel(new CustomVerifier("BindGoogleAuth"), SystemPlatform.FiiiPOS, accountId.ToString(), model);
        }
示例#10
0
        public LoginOM NewDeviceLogin(NewDeviceLoginIM im, string deviceNumber)
        {
            var user           = CheckUser(im.CountryId, im.Cellphone, im.Password);
            var customVerifier = new CustomVerifier("NewDeviceLogin");

            SecurityVerify.SetModel(customVerifier, SystemPlatform.FiiiPay, user.Id.ToString(), new NewDeviceLogin());

            SecurityVerify.Verify <NewDeviceLogin>(customVerifier, SystemPlatform.FiiiPay, user.Id.ToString(), (m) =>
            {
                bool result = true;
                if (user.L1VerifyStatus == VerifyStatus.Certified)
                {
                    var identityNo = new UserProfileComponent().PreVerifyLv1(user).IdentityDocNo;
                    result         = result && new IDNumberVerifier().Verify(SystemPlatform.FiiiPay, user.Id.ToString(), identityNo, im.IdentityDocNo);
                    if (!result)
                    {
                        var errorCountKey = customVerifier.GetErrorCountKey(SystemPlatform.FiiiPay, user.Id.ToString());
                        var errorCount    = SecurityVerify.CheckErrorCount(customVerifier, errorCountKey);
                        new IDNumberVerifier().VerifyFaild(Constant.VIRIFY_FAILD_TIMES_LIMIT - errorCount - 1);
                    }
                }
                if (!string.IsNullOrEmpty(user.Pin))
                {
                    result = result && new PinVerifier().Verify(SystemPlatform.FiiiPay, user.Id.ToString(), user.Pin, AES128.Decrypt(im.Pin, AES128.DefaultKey));
                    if (!result)
                    {
                        var errorCountKey = customVerifier.GetErrorCountKey(SystemPlatform.FiiiPay, user.Id.ToString());
                        var errorCount    = SecurityVerify.CheckErrorCount(customVerifier, errorCountKey);
                        new PinVerifier().VerifyFaild(Constant.VIRIFY_FAILD_TIMES_LIMIT - errorCount - 1);
                    }
                }
                if (SecurityVerify.CheckSecurityOpened(user.ValidationFlag, ValidationFlag.GooogleAuthenticator))
                {
                    var googleVerifier = new GoogleVerifier();
                    if (string.IsNullOrEmpty(im.GoogleCode))
                    {
                        result = false;
                    }
                    result = result && SecurityVerify.CheckCodeValid(googleVerifier, SystemPlatform.FiiiPay, user.Id.ToString(), im.GoogleCode);
                    result = result && googleVerifier.Verify(user.AuthSecretKey, im.GoogleCode);
                    if (!result)
                    {
                        var errorCountKey = customVerifier.GetErrorCountKey(SystemPlatform.FiiiPay, user.Id.ToString());
                        var errorCount    = SecurityVerify.CheckErrorCount(customVerifier, errorCountKey);
                        googleVerifier.VerifyFaild(Constant.VIRIFY_FAILD_TIMES_LIMIT - errorCount - 1);
                    }
                }

                return(result);
            });

            new UserDeviceDAC().Insert(new UserDevice()
            {
                DeviceNumber = deviceNumber, Name = " ", UserAccountId = user.Id, LastActiveTime = DateTime.UtcNow
            });

            return(IssueAccessToken(user));
        }
        public void VerifyOpenGoogleAuth(UserAccount user, string code)
        {
            SecurityVerify.Verify(new GoogleVerifier(), SystemPlatform.FiiiPay, user.Id.ToString(), user.AuthSecretKey, code);
            var model = new OpenGoogleAuth {
                GoogleVerified = true
            };

            SecurityVerify.SetModel(new CustomVerifier("OpenGoogleAuth"), SystemPlatform.FiiiPay, user.Id.ToString(), model);
        }
示例#12
0
        public void VerifyUpdateCellphoneNewCode(UserAccount user, VerifyUpdateCellphoneNewCodeIM im)
        {
            SecurityVerify.Verify(new UpdateCellphoneNewVerifier(), SystemPlatform.FiiiPay, user.Id.ToString(), im.Code);

            var model = SecurityVerify.GetModel <UpdateCellphoneVerify>(new CustomVerifier("UpdateCellphone"), SystemPlatform.FiiiPay, user.Id.ToString());

            model.NewCellphoneVerified = true;
            SecurityVerify.SetModel(new CustomVerifier("UpdateCellphone"), SystemPlatform.FiiiPay, user.Id.ToString(), model);
        }
示例#13
0
        public void VerifySetEmailPin(Guid accountId, string pin)
        {
            var account = new MerchantAccountDAC().GetById(accountId);

            SecurityVerify.Verify(new PinVerifier(), SystemPlatform.FiiiPOS, account.Id.ToString(), account.PIN, pin);
            var model = SecurityVerify.GetModel <FiiiPosSetEmailVerify>(new CustomVerifier("SetEmail"), SystemPlatform.FiiiPOS, account.Id.ToString());

            model.PinVerified = true;
            SecurityVerify.SetModel(new CustomVerifier("SetEmail"), SystemPlatform.FiiiPOS, account.Id.ToString(), model);
        }
        public void VerificationSMSCode(int countryId, string cellphone, string code)
        {
            SecurityVerify.Verify(new FiiiPosRegisterVerifier(), SystemPlatform.FiiiPOS, $"{countryId}{cellphone}", code);
            var model = new FiiiPosSignUpVerify
            {
                CellphoneVerified = true
            };

            SecurityVerify.SetModel(new CustomVerifier("FiiiPosSignUp"), SystemPlatform.FiiiPOS, $"{countryId}:{cellphone}", model);
        }
示例#15
0
        public void VerifyForgotPasswordCode(int countryId, string cellphone, string code)
        {
            SecurityVerify.Verify(new ForgetPasswordCellphoneVerifier(), SystemPlatform.FiiiPay, $"{countryId}:{cellphone}", code);
            var model = new ResetPasswordVerify
            {
                CellphoneVerified = true
            };

            SecurityVerify.SetModel(new CustomVerifier("ForgotPassword"), SystemPlatform.FiiiPay, $"{countryId}:{cellphone}", model);
        }
示例#16
0
        public void VerifyUpdateCellphonePin(UserAccount user, string pin)
        {
            SecurityVerify.Verify(new PinVerifier(), SystemPlatform.FiiiPay, user.Id.ToString(), user.Pin, pin);
            var model = new UpdateCellphoneVerify
            {
                PinVerified = true
            };

            SecurityVerify.SetModel(new CustomVerifier("UpdateCellphone"), SystemPlatform.FiiiPay, user.Id.ToString(), model);
        }
示例#17
0
        public void VerifyUpdatePasswordPin(UserAccount user, string code)
        {
            SecurityVerify.Verify(new PinVerifier(), SystemPlatform.FiiiPay, user.Id.ToString(), user.Pin, code);

            var model = new UpdatePasswordVerify
            {
                PinVerified = true
            };

            SecurityVerify.SetModel(new CustomVerifier("UpdatePassword"), SystemPlatform.FiiiPay, user.Id.ToString(), model);
        }
        public void VerifyGoogleAuthByMerchantAccount(string googleCode, string merchantAccount)
        {
            var dac     = new MerchantAccountDAC();
            var account = dac.GetByUsername(merchantAccount);

            SecurityVerify.Verify(new GoogleVerifier(), SystemPlatform.FiiiPOS, account.Id.ToString(), account.AuthSecretKey, googleCode);
            var model = SecurityVerify.GetModel <BindAccountVerify>(new CustomVerifier("BindAccount"), SystemPlatform.FiiiPOS, merchantAccount);

            model.GoogleVerified = true;
            SecurityVerify.SetModel(new CustomVerifier("BindAccount"), SystemPlatform.FiiiPOS, merchantAccount, model);
        }
        public void VerifyBindPin(UserAccount user, string pin)
        {
            SecurityVerify.Verify(new PinVerifier(), SystemPlatform.FiiiPay, user.Id.ToString(), user.Pin, pin);

            var model = new BindGoogleAuth
            {
                PinVerified = true
            };

            SecurityVerify.SetModel(new CustomVerifier("BindGoogleAuth"), SystemPlatform.FiiiPay, user.Id.ToString(), model);
        }
        public void VerifyPINByMerchantAccount(string pin, string merchantAccount)
        {
            var dac     = new MerchantAccountDAC();
            var account = dac.GetByUsername(merchantAccount);

            SecurityVerify.Verify(new PinVerifier(), SystemPlatform.FiiiPOS, account.Id.ToString(), account.PIN, pin);
            var model = SecurityVerify.GetModel <BindAccountVerify>(new CustomVerifier("BindAccount"), SystemPlatform.FiiiPOS, merchantAccount);

            model.PinVerified = true;
            SecurityVerify.SetModel(new CustomVerifier("BindAccount"), SystemPlatform.FiiiPOS, merchantAccount, model);
        }
示例#21
0
        public void VerifyOpenGoogleAuth(Guid merchantId, string code)
        {
            var merchant = new MerchantAccountDAC().GetById(merchantId);

            SecurityVerify.Verify(new GoogleVerifier(), SystemPlatform.FiiiPOS, merchant.Id.ToString(), merchant.AuthSecretKey, code);
            var model = new OpenGoogleAuth {
                GoogleVerified = true
            };

            SecurityVerify.SetModel(new CustomVerifier("OpenGoogleAuth"), SystemPlatform.FiiiPOS, merchant.Id.ToString(), model);
        }
示例#22
0
        public void VerifyBindPin(Guid accountId, string pin)
        {
            var merchant = new MerchantAccountDAC().GetById(accountId);

            SecurityVerify.Verify(new PinVerifier(), SystemPlatform.FiiiPOS, merchant.Id.ToString(), merchant.PIN, pin);

            var model = new BindGoogleAuth
            {
                PinVerified = true
            };

            SecurityVerify.SetModel(new CustomVerifier("BindGoogleAuth"), SystemPlatform.FiiiPOS, merchant.Id.ToString(), model);
        }
        public void VerifyWithdrawPIN(Guid accountId, string pin)
        {
            UserAccount user = new UserAccountDAC().GetById(accountId);

            SecurityVerify.Verify(new PinVerifier(), SystemPlatform.FiiiPay, accountId.ToString(), user.Pin, pin);

            var model = new WithdrawVerify
            {
                PinVerified = true
            };

            SecurityVerify.SetModel(new CustomVerifier("UserWithdraw"), SystemPlatform.FiiiPay, accountId.ToString(), model);
        }
        public void VerifyWithdrawPIN(Guid accountId, string pin)
        {
            MerchantAccount account = new MerchantAccountDAC().GetById(accountId);

            SecurityVerify.Verify(new PinVerifier(), SystemPlatform.FiiiPOS, accountId.ToString(), account.PIN, pin);

            var model = new WithdrawVerify
            {
                PinVerified = true
            };

            SecurityVerify.SetModel(new CustomVerifier("MerchantWithdraw"), SystemPlatform.FiiiPOS, accountId.ToString(), model);
        }
        public void VerifyUnBindAccountPin(Guid merchantId, string pin)
        {
            var merchant = new MerchantAccountDAC().GetById(merchantId);

            SecurityVerify.Verify(new PinVerifier(), SystemPlatform.FiiiPOS, merchant.Id.ToString(), merchant.PIN, pin);

            var model = new UnBindAccountVerify
            {
                PinVerified = true
            };

            SecurityVerify.SetModel(new CustomVerifier("UnBindAccount"), SystemPlatform.FiiiPOS, merchant.Id.ToString(), model);
        }
示例#26
0
        public void VerifySetEmailCode(Guid accountId, string code)
        {
            var account = new MerchantAccountDAC().GetById(accountId);

            if (!string.IsNullOrEmpty(account.Email))
            {
                throw new ApplicationException();
            }

            SecurityVerify.Verify(new SetEmailVerifier(), SystemPlatform.FiiiPOS, account.Id.ToString(), code);
            var model = SecurityVerify.GetModel <FiiiPosSetEmailVerify>(new CustomVerifier("SetEmail"), SystemPlatform.FiiiPOS, account.Id.ToString());

            model.EmailVerified = true;
            SecurityVerify.SetModel(new CustomVerifier("SetEmail"), SystemPlatform.FiiiPOS, account.Id.ToString(), model);
        }
示例#27
0
        public void VerifyModifyCellphonePIN(Guid accountId, string pin)
        {
            MerchantAccount merchant = new MerchantAccountDAC().GetById(accountId);

            if (merchant == null)
            {
                throw new CommonException(ReasonCode.ACCOUNT_NOT_EXISTS, Resources.用户不存在);
            }
            SecurityVerify.Verify(new PinVerifier(), SystemPlatform.FiiiPOS, accountId.ToString(), merchant.PIN, pin);

            var model = new ModifyCellphoneVerify
            {
                PinVerified = true
            };

            SecurityVerify.SetModel(new CustomVerifier("ModifyCellphone"), SystemPlatform.FiiiPOS, accountId.ToString(), model);
        }
示例#28
0
        public void VerifyUpdateOriginalEmail(Guid accountId, string emailAddress, string code)
        {
            var dac     = new MerchantAccountDAC();
            var account = dac.GetById(accountId);

            if (account.Email != emailAddress)
            {
                throw new CommonException(ReasonCode.EMAIL_NOT_MATCH, Resources.原邮箱地址不正确);
            }

            SecurityVerify.Verify(new UpdateEmailOriginalVerifier(), SystemPlatform.FiiiPOS, accountId.ToString(), code);
            var model = new FiiiPosUpdateEmailVerify
            {
                OriginalEmailVerified = true
            };

            SecurityVerify.SetModel(new CustomVerifier("UpdateEmail"), SystemPlatform.FiiiPOS, accountId.ToString(), model);
        }
示例#29
0
        public LoginOM LoginBySMSCode(int countryId, string cellphone, string code, string deviceNumber)
        {
            var verifier = new LoginCellphoneVerifier();

            SecurityVerify.Verify(verifier, SystemPlatform.FiiiPay, $"{countryId}:{cellphone}", code);

            var user = CheckUser(countryId, cellphone);
            var isNeedGoogleVerify =
                ValidationFlagComponent.CheckSecurityOpened(user.ValidationFlag, ValidationFlag.GooogleAuthenticator);

            var deviceList = new UserDeviceDAC().GetUserDeviceByAccountId(user.Id);

            var isNewDevice = deviceList.All(item => item.DeviceNumber != deviceNumber);

            if (!deviceList.Any())
            {
                if (!string.IsNullOrEmpty(user.Pin) && !user.IsBindingDevice)
                {
                    new UserDeviceDAC().Insert(new UserDevice()
                    {
                        DeviceNumber = deviceNumber, Name = " ", UserAccountId = user.Id, LastActiveTime = DateTime.UtcNow
                    });

                    new UserAccountDAC().UpdateIsBindingDevice(user.Id);
                    isNewDevice = false;
                }
            }

            if (isNeedGoogleVerify || (isNewDevice && !string.IsNullOrEmpty(user.Pin)))
            {
                string loginTypeName = isNewDevice ? "NewDeviceLogin" : "LoginBySMS";
                var    model         = new LoginBySMSVerify
                {
                    CellphoneVerified = true
                };
                SecurityVerify.SetModel(new CustomVerifier(loginTypeName), SystemPlatform.FiiiPay, user.Id.ToString(), model);
                return(new LoginOM()
                {
                    IsNeedGoogleVerify = isNeedGoogleVerify, IsNewDevice = isNewDevice, UserInfo = GetUserVerifyItems(user)
                });
            }

            return(IssueAccessToken(user));
        }
示例#30
0
        /// <summary>
        /// 验证原邮箱
        /// </summary>
        /// <param name="user"></param>
        /// <param name="email"></param>
        /// <param name="code"></param>
        public void VerifyOriginalEmail(UserAccount user, string email, string code)
        {
            if (string.IsNullOrEmpty(user.Email))
            {
                throw new ApplicationException(MessageResources.NotBindMail);
            }
            if (user.Email != email)
            {//必须要相等
                throw new CommonException(ReasonCode.EMAIL_NOT_MATCH, MessageResources.IncorrectOriginalEmailAddress);
            }

            SecurityVerify.Verify(new UpdateEmailOriginalVerifier(), SystemPlatform.FiiiPay, user.Id.ToString(), code);
            var model = new UpdateEmailVerify
            {
                OriginalEmailVerified = true
            };

            SecurityVerify.SetModel(new CustomVerifier("UpdateEmail"), SystemPlatform.FiiiPay, user.Id.ToString(), model);
        }