示例#1
0
        private static FuncResult <int?> GetIntroducerId(string refereeCode)
        {
            if (string.IsNullOrEmpty(refereeCode) && AppConfig.RegisterRefereeRequired)
            {
                return(FuncResult.FailResult <int?>("必须填写推荐人"));
            }

            if (string.IsNullOrEmpty(refereeCode))
            {
                return(FuncResult.SuccessResult(default(int?)));
            }
            var   fac         = UserModuleFactory.GetUserModuleInstance();
            IUser refereeUser = null;

            if (refereeCode.StartsWith("U"))
            {
                refereeUser = fac?.GetUserByCode(refereeCode);
            }
            else
            {
                int userid;
                if (!int.TryParse(refereeCode.Replace("U", ""), out userid))
                {
                    return(FuncResult.FailResult <int?>("无效的邀请码"));
                }
                refereeUser = fac?.GetUserByID(userid);
            }
            if (refereeUser == null)
            {
                return(FuncResult.FailResult <int?>("推荐人账号不存在"));
            }
            return(FuncResult.SuccessResult(refereeUser?.UserId));
        }
 public FuncResult Handler(string userCode, string userPwd, string mobileno, string smsContent)
 {
     try
     {
         Tsms_Thirdparty daThirdparty = null;
         string          error;
         if (!SmsUtils.CheckUserCode(userCode, userPwd, mobileno, out daThirdparty, out error))
         {
             return(FuncResult.FailResult(error));
         }
         ISmsProvider sms = SmsServiceFactory.GetSmsServiceByChannel(daThirdparty.Channel_Id, out error);
         if (sms == null)
         {
             return(FuncResult.FailResult(error));
         }
         SmsServiceProvider provider = new SmsServiceProvider(sms, daThirdparty.Appid, mobileno, smsContent);
         if (!provider.Send())
         {
             return(FuncResult.FailResult(provider.PromptInfo.CustomMessage));
         }
         return(FuncResult.SuccessResult());
     }
     catch (Exception ex)
     {
         Log.Error("handler异常", ex);
         return(FuncResult.FailResult(ex.Message));
     }
 }
示例#3
0
        // 上传文件到服务器
        public JsonResult Service()
        {
            List <IPostFileData> list = new List <IPostFileData>();

            foreach (string key in Request.Files.Keys)
            {
                HttpPostedFileBase file     = Request.Files[key];
                string             filename = file.FileName;
                if (filename.IndexOf(".") < 0)
                {
                    filename = filename + ".jpg";
                }
                byte[] filebytes = new byte[file.ContentLength];
                file.InputStream.Read(filebytes, 0, filebytes.Length);
                PostFileData data = new PostFileData();
                data.FileName = file.FileName;
                data.Name     = key;
                data.Value    = filebytes;

                list.Add(data);
            }
            Log.Info("收到图片{0}张", list.Count);
            if (list.Count <= 0)
            {
                return(Json(FuncResult.FailResult("请上传图片", (int)ApiStatusCode.BAD_REQUEST)));
            }
            FileSystemClient client = new FileSystemClient(AppConfig.FileSystem_AppID, AppConfig.FileSystem_AppSecret);
            var res = client.UploadFile(list.ToArray());

            return(Json(res));
        }
示例#4
0
        public FuncResult <ThirdPartyLoginResult> Login(int clientSource, string clientSys, string deviceId, string clientVer, string ipAddress, string session_id, int appId)
        {
            if (this._user == null)
            {
                return(FuncResult.FailResult <ThirdPartyLoginResult>("未注册", 404));
            }
            LoginProvider localLogin = new LoginProvider(_user.UserCode, null, "basic");

            localLogin.IgnorePassword = true;
            if (!localLogin.Login(clientSource, clientSys, deviceId, ipAddress, session_id, clientVer, appId))
            {
                return(FuncResult.FailResult <ThirdPartyLoginResult>(localLogin.PromptInfo.CustomMessage, (int)localLogin.PromptInfo.ResultType));
            }
            var data = new ThirdPartyLoginResult
            {
                Token          = localLogin.Token,
                UserCode       = _user.UserCode,
                Expires        = localLogin.OAuthUser.Expire_In,
                RefreshExpires = localLogin.OAuthUser.Refresh_Expire_In,
                RefreshToken   = localLogin.OAuthUser.Refresh_Token,
                Openid         = localLogin.OAuthUser.Open_Id
            };

            return(FuncResult.SuccessResult(data));
        }
        public FuncResult Handler(string interfaceName, string dataJson)
        {
            FuncResult result = new FuncResult();

            try
            {
                if ("sms_service".Equals(interfaceName, StringComparison.OrdinalIgnoreCase))
                {
                    var args = JsonProvider.JsonTo <SmsArgs>(dataJson);
                    if (args == null)
                    {
                        return(FuncResult.FailResult("参数为空"));
                    }
                    result = this.Handler(args.UserCode, args.UserPwd, args.Mobileno, args.Content);
                }
                else if ("validate_code_send_service".Equals(interfaceName, StringComparison.OrdinalIgnoreCase))
                {
                    var args = JsonProvider.JsonTo <SendValidateCodeArgs>(dataJson);
                    if (args == null)
                    {
                        return(FuncResult.FailResult("参数为空"));
                    }
                    SmsValidCodeFacade valid = new SmsValidCodeFacade(args.UserCode, args.UserPwd);
                    bool res = valid.SendSmsValidCode(args.Mobileno, args.Gid, args.AppName);
                    result.Success    = res;
                    result.Message    = res ? null : valid.PromptInfo.CustomMessage;
                    result.StatusCode = res ? 1 : 4;
                }
                else if ("validate_code_verify_service".Equals(interfaceName, StringComparison.OrdinalIgnoreCase))
                {
                    var args = JsonProvider.JsonTo <CodeVerificationArgs>(dataJson);
                    if (args == null)
                    {
                        return(FuncResult.FailResult("参数为空"));
                    }
                    SmsValidCodeFacade valid = new SmsValidCodeFacade(args.UserCode, args.UserPwd);
                    bool isSuccess           = valid.ValidSmsCode(args.Mobileno, args.Gid, args.Code);
                    result.Success    = isSuccess;
                    result.Message    = isSuccess ? null : valid.PromptInfo.CustomMessage;
                    result.StatusCode = isSuccess ? 1 : 4;
                }
                else
                {
                    result.Success    = false;
                    result.Message    = "未找到指定的服务[" + interfaceName + "]";
                    result.StatusCode = 404;
                }
            }
            catch (Exception ex)
            {
                Log.Error("API-Handler异常", ex);
                result.Success    = false;
                result.Message    = "系统错误";
                result.StatusCode = 500;
            }
            return(result);
        }
示例#6
0
        /// <summary>
        /// 获取账单
        /// </summary>
        /// <returns></returns>
        public ActionResult List(TradeDetailsArgs arg)
        {
            UserPurseProvider upp = new UserPurseProvider();
            FuncResult <Winner.Balance.WebService.Client.Modes.UserPurse> purseResult = null;
            eBankAccountType acctType = (eBankAccountType)arg.AccountType;

            switch (acctType)
            {
            case eBankAccountType.金币:
                purseResult = upp.UserGoldCoinPurse(Package.UserId);
                break;

            case eBankAccountType.现金:
                purseResult = upp.UserCashPurse(Package.UserId);
                break;
            }
            if (purseResult == null)
            {
                return(Json(FuncResult.FailResult("未找到账单信息", (int)ApiStatusCode.DATA_QUERY_FAIL)));
            }

            if (!purseResult.Success)
            {
                return(Json(purseResult));
            }

            QueryProvider qp             = new QueryProvider();
            var           purseHisResult = qp.PurseHis(purseResult.Content.PurseCode, null, arg.PageIndex, arg.PageSize, arg.StartDate, arg.EndDate);

            if (!purseHisResult.Success)
            {
                return(Json(purseHisResult));
            }
            FuncResult <object> listResult = new FuncResult <object>();

            listResult.Success    = true;
            listResult.Message    = null;
            listResult.StatusCode = 1;
            if (purseHisResult.Content != null && purseHisResult.Content.Data != null)
            {
                List <object> list = new List <object>();
                foreach (var item in purseHisResult.Content.Data)
                {
                    var li = new
                    {
                        Createtime = item.Createtime,
                        Amount     = item.Amount,
                        Remarks    = item.Remarks
                    };
                    list.Add(li);
                }
                listResult.Content = PageList <object> .Instance(arg.PageIndex, arg.PageSize, purseHisResult.Content.Count, list);
            }
            return(Json(listResult));
        }
示例#7
0
        public FuncResult <ThirdPartyLoginResult> Login(Winner.WebApi.Contract.ApiPackage package, string ipAddress, string session_id, int appId)
        {
            //ThirdParty、OpenId
            bool           isExist = false;
            int            userId  = 0;
            Tnet_User_Auth daAuth  = new Tnet_User_Auth();

            if (!(isExist = daAuth.SelectByThirdparty_OpenId((int)this._thirdParty, this._openID)))
            {
                //if not exist
                //add one
                userId            = GetNewUserId();
                daAuth.Open_Id    = this._openID;
                daAuth.Status     = 1;
                daAuth.Thirdparty = (int)this._thirdParty;
                daAuth.User_Id    = userId;
                if (!daAuth.Insert())
                {
                    //Alert("登录失败,保存登录信息异常");
                    return(FuncResult.FailResult <ThirdPartyLoginResult>("登录失败,保存登录信息异常"));
                }
            }
            else
            {
                userId = daAuth.User_Id;
            }
            if (!isExist)
            {
                return(FuncResult.SuccessResult((ThirdPartyLoginResult)null));
            }
            var   fac  = UserModuleFactory.GetUserModuleInstance();
            IUser user = fac.GetUserByID(userId);

            if (user == null)
            {
                return(FuncResult.SuccessResult((ThirdPartyLoginResult)null));
            }
            LoginProvider localLogin = new LoginProvider(user.UserCode, null);

            localLogin.IgnorePassword = true;
            if (!localLogin.Login(package.ClientSource, package.ClientSystem, package.Device_Id, ipAddress, session_id, package.ClientVersion, appId))
            {
                return(FuncResult.FailResult <ThirdPartyLoginResult>(localLogin.PromptInfo.CustomMessage, (int)localLogin.PromptInfo.ResultType));
            }
            var data = new ThirdPartyLoginResult
            {
                Token    = localLogin.Token,
                UserCode = user.UserCode
            };

            return(FuncResult.SuccessResult(data));
        }
示例#8
0
        /// <summary>
        /// 创建GPU订单
        /// </summary>
        /// <returns></returns>
        private FuncResult <GpuOrder> CreateGpuOrder(IUser user, string order_no, decimal amount, PayType PayType)
        {
            string subject   = string.Concat(_arg.OrderType, "升级");
            var    currency  = new Currency(CurrencyType.RMB, amount);
            string notifyUrl = AppConfig.GpuNotifyReceiveUrl;
            var    gpuPay    = new GpuQuickPaymentProvider(user, subject, order_no, currency, (GpuPayType)PayType, TransferReason.升级VIP, notifyUrl);

            gpuPay.SetPrivateValue(AppConfig.VIPORDER_PRIVATE_VALUE);
            GpuOrder order = gpuPay.CreateOrder();

            if (order == null)
            {
                return(FuncResult.FailResult <GpuOrder>(gpuPay.PromptInfo.CustomMessage));
            }
            return(FuncResult.SuccessResult(order));
        }
示例#9
0
        public override void OnException(ExceptionContext filterContext)
        {
            string currentUrl = filterContext.HttpContext.Request.Url.AbsoluteUri;

            Log.Error(currentUrl + "异常", filterContext.Exception);
            if (filterContext.Controller is ApiControllerBase)
            {
                string errorMessage = Debuger.IsDebug ? filterContext.Exception.Message : "服务器异常";
                filterContext.Result = new Javirs.Common.MVC.NewtonJsonResult
                {
                    Data = FuncResult.FailResult(errorMessage, 500)
                };
                filterContext.ExceptionHandled = true;

                return;
            }
            base.OnException(filterContext);
        }
示例#10
0
        public FuncResult <IParameterModel> Resolve(ReverseProxyContext context)
        {
            var result = GetParameterModel(context.HttpMethod, context.InputStream, context.Query);

            if (!result.Success)
            {
                return(result);
            }
            var signV = result.Content.VerifySignature();

            if (!signV.Success)
            {
                return(FuncResult.FailResult <IParameterModel>(signV.Message, signV.StatusCode));
            }
            ContentType contentType = "GET".Equals(context.HttpMethod, StringComparison.OrdinalIgnoreCase) ? ContentType.form_urlencoded : ContentType.json;

            context.DataModel    = result.Content;
            context.ForwardValue = new ProxyForwardValue(context.DataModel.GetBizContent(), contentType);
            return(FuncResult.SuccessResult(context.DataModel));
        }
示例#11
0
        public ActionResult Authorize(string appid, string scope, string state, string redirect_uri, string user_code, string login_pwd, GrantCodeRight[] grants, int takeAll)
        {
            string     device_id  = Request.Headers["device-id"];
            OAuthApp   app        = OAuthAppCache.Instance.Find(it => it.APP_CODE.Equals(appid));
            GrantScope scopeModel = ScopeCache.Instance.Find(it => it.SCOPE_CODE.Equals(scope));

            if (app == null)
            {
                return(View("fatal", FuncResult.FailResult("未注册的应用")));
            }
            if (scopeModel == null)
            {
                return(View("fatal", FuncResult.FailResult("无效的授权范围")));
            }
            if (!this.OAuthContext.IsLogined)
            {
                if (string.IsNullOrEmpty(user_code))
                {
                    return(View("fatal", FuncResult.FailResult("必须输入账号")));
                }
                if (string.IsNullOrEmpty(login_pwd))
                {
                    return(View("fatal", FuncResult.FailResult("必须输入密码")));
                }
                string message;
                if (!this.UserLogin(user_code, login_pwd, app.APP_ID, out message))
                {
                    return(View("fatal", FuncResult.FailResult(message)));
                }
            }
            user_code = this.OAuthContext.UserInfo.UserCode;
            GrantProvider grant = new GrantProvider(appid, user_code, scope, device_id ?? this.OAuthContext.Device_Id);

            if (!grant.Grant(takeAll == 1, grants))
            {
                return(View("fatal", FuncResult.FailResult("授权失败,请重试")));
            }
            string return_url = xUtils.CombinaRedirectUri(redirect_uri, state, grant.Auth_Code);

            return(Redirect(return_url));
        }
示例#12
0
        public FuncResult VerifySignature()
        {
            IMerchant merchant = GetMerchant();

            if (merchant == null)
            {
                return(FuncResult.FailResult("无效商户号", 400));
            }
            AsciiSortedDictionary <object> dic = JsonSerializer.Deserializer <AsciiSortedDictionary <object> >(GetRequestOriginalString());

            dic.Remove(item => item.Key.Equals("sign", StringComparison.OrdinalIgnoreCase) || item.Value == null || string.IsNullOrEmpty(item.Value.ToString()));
            StringBuilder builder = new StringBuilder();

            dic.Aggregate(builder, (b, kv) => b.Append(kv.Key).Append("=").Append(kv.Value).Append("&"));
            builder.Remove(builder.Length - 1, 1);
            bool res = merchant.VerifySignature(builder.ToString(), GetRequestSignature());

            return(new FuncResult {
                Success = res, Message = "签名验证不正确", StatusCode = 2
            });
        }
        protected override FuncResult <IParameterModel> GetParameterModel(string httpMethod, Stream inputStream, IQueryCollection query)
        {
            GatewayParameterModel dataModel;

            if ("POST".Equals(httpMethod, StringComparison.OrdinalIgnoreCase))
            {
                string postData = null;
                using (StreamReader reader = new StreamReader(inputStream))
                {
                    postData = reader.ReadToEnd();
                }
                if (string.IsNullOrEmpty(postData))
                {
                    return(FuncResult.FailResult <IParameterModel>("无效报文", 405));
                }
                dataModel = JsonSerializer.Deserializer <GatewayParameterModel>(postData);
                dataModel.RequestOriginalString = postData;
            }
            else if ("GET".Equals(httpMethod, StringComparison.OrdinalIgnoreCase))
            {
                dataModel            = new GatewayParameterModel();
                dataModel.Data       = query["data"];
                dataModel.Sign       = query["sign"];
                dataModel.MerchantNo = query["merchantNo"];
                dataModel.Service    = query["service"];
                dataModel.Timestamp  = Convert.ToInt64(query["timestamp"]);
                StringBuilder sb = new StringBuilder();
                query.Aggregate(sb, (b, kv) => b.Append(kv.Key).Append("=").Append(kv.Value).Append("&"));
                if (sb.Length > 1)
                {
                    sb.Remove(sb.Length - 1, 1);
                }
                dataModel.RequestOriginalString = sb.ToString();
            }
            else
            {
                return(FuncResult.FailResult <IParameterModel>("不支持的请求头", 415));
            }
            return(FuncResult.SuccessResult((IParameterModel)dataModel));
        }
示例#14
0
        public JsonResult List()
        {
            var user = xUtils.GetUserByCode(Package.UserCode);

            if (user == null)
            {
                return(Json(FuncResult.FailResult("用户未注册", 404)));
            }
            Tnet_Bank_AccountCollection daAcctColl = new Tnet_Bank_AccountCollection();

            daAcctColl.ListByUserId(user.UserId);
            List <object> list = new List <object>();

            foreach (Tnet_Bank_Account acct in daAcctColl)
            {
                var card = new
                {
                    Card_Id       = acct.Id,
                    CardHolder    = acct.Account_Name,
                    Card_No       = acct.Card_No,
                    Bank_Id       = acct.Bank_Id,
                    Branch_Name   = acct.Branch_Bank,
                    Branch_No     = acct.Branch_No,
                    Bank_Name     = acct.Bank_Name,
                    Province_Name = acct.Province_Name,
                    City_Name     = acct.City_Name,
                    Status        = acct.Status,
                    Createtime    = acct.Createtime,
                    RefuseReason  = xUtils.GetValidateRemarks(acct.Remarks),
                };
                list.Add(card);
            }
            FuncResult <object> result = new FuncResult <object>();

            result.Success    = true;
            result.Message    = null;
            result.StatusCode = 1;
            result.Content    = list;
            return(Json(result));
        }
示例#15
0
 public JsonResult Delete(int Card_Id)
 {
     return(Json(FuncResult.FailResult("not implement", 304)));
 }
        /// <summary>
        /// 创蓝通道发送短信,为SendNo赋值
        /// </summary>
        /// <param name="mobileno">目标手机号</param>
        /// <param name="msg">短信息内容</param>
        /// <param name="extno">扩展号码,纯数字(1-3位)</param>
        /// <returns></returns>
        private FuncResult SendSmsByChuangLan(string mobileno, string smsContent, string extno)
        {
            if (Debuger.IsDebug)
            {
                return(FuncResult.SuccessResult());
            }
            Dictionary <string, string> dic = new Dictionary <string, string>();

            dic.Add("0", "提交成功");
            dic.Add("101", "无此用户");
            dic.Add("102", "密码错");
            dic.Add("103", "提交过快(提交速度超过流速限制)");
            dic.Add("104", "系统忙(因平台侧原因,暂时无法处理提交的短信)");
            dic.Add("105", "敏感短信(短信内容包含敏感词)");
            dic.Add("106", "消息长度错(>536或<=0)");
            dic.Add("107", "包含错误的手机号码");
            dic.Add("108", "手机号码个数错(群发>50000或<=0;单发>200或<=0)");
            dic.Add("109", "无发送额度(该用户可用短信数已使用完)");
            dic.Add("110", "不在发送时间内");
            dic.Add("111", "超出该账户当月发送额度限制");
            dic.Add("112", "无此产品,用户没有订购该产品");
            dic.Add("113", "extno格式错(非数字或者长度不对)");
            dic.Add("115", "自动审核驳回");
            dic.Add("116", "签名不合法,未带签名(用户必须带签名的前提下)");
            dic.Add("117", "IP地址认证错,请求调用的IP地址不是系统登记的IP地址");
            dic.Add("118", "用户没有相应的发送权限");
            dic.Add("119", "用户已过期");
            dic.Add("120", "短信内容不在白名单中");

            //string postStrTpl = "account={0}&pswd={1}&mobile={2}&msg={3}&needstatus=true&product=&extno={4}";
            string       postStrTpl = "un={0}&pw={1}&phone={2}&msg={3}&rd=1";
            UTF8Encoding encoding   = new UTF8Encoding();

            byte[] postData = encoding.GetBytes(string.Format(postStrTpl, this._channel.Access_Name, this._channel.Access_Key,
                                                              mobileno, smsContent));

            try
            {
                HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(this._channel.Service_Url);
                myRequest.Method        = "POST";
                myRequest.ContentType   = "application/x-www-form-urlencoded";
                myRequest.ContentLength = postData.Length;

                Stream newStream = myRequest.GetRequestStream();
                // Send the data.
                newStream.Write(postData, 0, postData.Length);
                newStream.Flush();
                newStream.Close();

                HttpWebResponse myResponse = (HttpWebResponse)myRequest.GetResponse();
                if (myResponse.StatusCode == HttpStatusCode.OK)
                {
                    StreamReader reader   = new StreamReader(myResponse.GetResponseStream(), Encoding.UTF8);
                    string       respText = reader.ReadToEnd();
                    Log.Info(respText);
                    TextReader tr      = new System.IO.StringReader(respText);
                    var        resText = tr.ReadLine();
                    var        msgid   = tr.ReadLine();
                    var        array   = resText.Split(',');
                    this.SendNo = msgid;
                    if (array[1] != "0")
                    {
                        string error = dic.ContainsKey(array[1]) ? dic[array[1]] : "发送失败";
                        return(FuncResult.FailResult(error));
                    }
                    return(FuncResult.SuccessResult());
                }
                return(FuncResult.FailResult("短信通道访问异常"));
            }
            catch (Exception ex)
            {
                return(FuncResult.FailResult("发送短信时出现系统繁忙!原因:" + ex.Message));
            }
        }
示例#17
0
        public ActionResult Authorize(string appid, string scope, string state, string redirect_uri)
        {
            string authHeader = Request.Headers["auth"];
            string device_id  = Request.Headers["device-id"];
            string appVersion = Request.Headers["app-version"];

            Log.Info("HTTP HEADER: auth={0}&device_id={1}&app-version={2}", authHeader, device_id, appVersion);
            if (!string.IsNullOrEmpty(authHeader))
            {
                scope = string.IsNullOrEmpty(scope) ? "basic_api" : scope;
                string message;
                try
                {
                    if (!this.LoginByToken(authHeader, device_id, appVersion, out message))
                    {
                        return(View("fatal", message));
                    }
                }
                catch (Exception ex)
                {
                    message = ex.Message;
                    Log.Info("APP登录失败", ex);
                    return(View("fatal", new { Message = message }));
                }
            }

            OAuthApp app = OAuthAppCache.Instance.Find(it => it.APP_CODE.Equals(appid));

            //var scopeModel = ScopeCache.Instance.Find(it => it.SCOPE_CODE.Equals(scope));
            GrantScope[] scopeModel = ScopeCache.Instance.FindAll(scope);
            if (scopeModel == null || scopeModel.Length <= 0)
            {
                return(View("fatal", FuncResult.FailResult("无效的授权范围")));
            }
            var scopeids    = scopeModel.Select(it => it.SCOPE_ID);
            var scopeRights = ScopeRightProvider.GetScopeRights(scopeids.ToArray());

            ViewBag.ScopeRights = scopeRights;
            if (app == null)
            {
                return(View("fatal", FuncResult.FailResult("未注册的应用")));
            }
            this.OAuthContext.CurrentApp = app;

            if (string.IsNullOrEmpty(redirect_uri))
            {
                return(View("fatal", FuncResult.FailResult("redirect_uri不能为空")));
            }
            if (this.OAuthContext.IsLogined)                                                                                //已登录
            {
                bool isAlreadyAuthorized = xUtils.IsAlreayAuthorized(app.APP_ID, this.OAuthContext.UserInfo.UserId, scope); //是否已授权

                if (app.IS_INTERNAL || !scopeModel.HasExpllicit() || isAlreadyAuthorized)                                   //内部应用、隐式授权作用域以及已经授权过
                {
                    GrantProvider provider = new GrantProvider(appid, this.OAuthContext.UserInfo.UserCode, scope, device_id ?? this.OAuthContext.Device_Id);
                    if (!provider.Grant(!isAlreadyAuthorized, null))//获取授权作用范围内所有权限
                    {
                        return(View("fatal", FuncResult.FailResult("授权失败")));
                    }
                    string auth_code  = provider.Auth_Code;
                    string return_url = xUtils.CombinaRedirectUri(redirect_uri, state, auth_code);
                    return(Redirect(return_url));
                }
                else
                {
                    //显式授权
                    return(View());
                }
            }
            else//未登录
            {
                if (app.IS_INTERNAL)
                {
                    return(View("Internal_Login"));
                }
                //登录后授权
                return(View());
            }
        }
示例#18
0
        public JsonResult ResetPassword(PasswordResetModel model)
        {
            Log.Debug(model.ToLineText());
            var fac = UserModuleFactory.GetUserModuleInstance();

            if (fac == null)
            {
                return(Json(FuncResult.FailResult("系统错误", 500)));
            }
            string newPwd       = model.New_Pwd;
            string validateCode = model.ValidateCode;

            if (model.PwdType == (int)PasswordType.支付密码)
            {
                if (!xUtils.RsaDecryptPayPwd(model.New_Pwd, out newPwd))
                {
                    return(Json(FuncResult.FailResult("新密码解密失败", (int)ApiStatusCode.DECRYPT_PASSWORD_FAIL)));
                }
                if (model.ValidateType == (int)IdentityValidateType.旧密码验证)
                {
                    if (!xUtils.RsaDecryptPayPwd(model.ValidateCode, out validateCode))
                    {
                        return(Json(FuncResult.FailResult("旧密码解密失败", (int)ApiStatusCode.DECRYPT_PASSWORD_FAIL)));
                    }
                }
            }
            IUser user = fac.GetUserByCode(Package.UserCode);

            if (user == null)
            {
                return(FailResult("用户账号[" + Package.UserCode + "]不存在"));
            }
            PasswordType          passwordType = (PasswordType)model.PwdType;
            var                   validateType = (IdentityValidateType)model.ValidateType;
            IIdentityVerification verification = IdentityVerificationFactory.GetVerification(validateType, user, passwordType, validateCode);

            if (verification == null)
            {
                return(Json(FuncResult.FailResult("指定的身份验证方式不正确", 409)));
            }

            IPasswordManager    pwdmgt = fac.GetPasswordManager(user);
            PasswordManagerArgs arg    = new PasswordManagerArgs
            {
                AlterSource  = xUtils.GetClientSource(this.Package.ClientSource),
                NewPassword  = newPwd,
                Pwd_Manager  = pwdmgt,
                Pwd_Type     = passwordType,
                Remarks      = string.Format("通过{0}修改", validateType.ToString()),
                UserId       = user.UserId,
                Use_Place    = this.Package.ClientSystem,
                Verification = verification
            };
            FuncResult          result  = new FuncResult();
            UserPasswordManager manager = new UserPasswordManager(arg);

            result.Success    = manager.Alter();
            result.Message    = result.Success ? null : manager.PromptInfo.CustomMessage;
            result.StatusCode = result.Success ? 1 : (int)manager.PromptInfo.ResultType;
            return(Json(result));
        }