Exemplo n.º 1
0
        ///<summary>Gets one InsVerify from the db that has the given fkey and verify type.</summary>
        public static InsVerify GetOneByFKey(long fkey, VerifyTypes verifyType)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetObject <InsVerify>(MethodBase.GetCurrentMethod(), fkey, verifyType));
            }
            string command = "SELECT * FROM insverify WHERE FKey=" + POut.Long(fkey) + " AND VerifyType=" + POut.Int((int)verifyType) + "";

            return(Crud.InsVerifyCrud.SelectOne(command));
        }
Exemplo n.º 2
0
        ///<summary>Deletes an InsVerify with the passed in FKey and VerifyType.</summary>
        public static void DeleteByFKey(long fkey, VerifyTypes verifyType)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                Meth.GetVoid(MethodBase.GetCurrentMethod(), fkey, verifyType);
                return;
            }
            long insVerifyNum = GetInsVerifyNumByFKey(fkey, verifyType);

            Crud.InsVerifyCrud.Delete(insVerifyNum);            //Will do nothing if insVerifyNum was 0.
        }
Exemplo n.º 3
0
        ///<summary>Gets one InsVerifyNum from the db that has the given fkey and verify type.</summary>
        public static long GetInsVerifyNumByFKey(long fkey, VerifyTypes verifyType)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetLong(MethodBase.GetCurrentMethod(), fkey, verifyType));
            }
            string    command   = "SELECT * FROM insverify WHERE FKey=" + POut.Long(fkey) + " AND VerifyType=" + POut.Int((int)verifyType) + "";
            InsVerify insVerify = Crud.InsVerifyCrud.SelectOne(command);

            if (insVerify == null)
            {
                return(0);
            }
            return(insVerify.InsVerifyNum);
        }
Exemplo n.º 4
0
        public ActionResponse <VerificationCodeViewModel> GetverificationCode(string mobile, VerifyTypes type)
        {
            bool firstRequest = false;
            var  checkMobile  = new AuthQueryResponse(Constants.Success);

            switch (type)
            {
            case VerifyTypes.SignUp:
                checkMobile = QueryByMobile(mobile);
                break;

            case VerifyTypes.BindWeChatUser:
                checkMobile = QueryWxUserByMobile(mobile);
                break;

            case VerifyTypes.Withdraw:
            case VerifyTypes.FindPassword:
                throw new NotImplementedException(type.ToString());
            }

            if (checkMobile.ErrorCode == Constants.MobileExists)
            {
                return(new ActionResponse <VerificationCodeViewModel>(Constants.MobileExists));
            }
            var result = GetVerificationCode(mobile, true);
            var span   = DateTime.UtcNow.Subtract(result.CreatedAt);

            if (span.TotalMinutes <= 2 && result.RequestCount > 1)
            {
                return(new ActionResponse <VerificationCodeViewModel>(Constants.FrequencyLimit));
            }
            return(new ActionResponse <VerificationCodeViewModel>(Constants.Success, result));
        }