Beispiel #1
0
        public ActionResult updateAccount(string oldaccount, string account, string accounttype, string verifykey)
        {
            var code = Config.UserConfig.getVerifyCode(account);

            if (code != null && code.Code.Equals(verifykey.ToLower()))
            {
                using (var manage = new bitcms.Data.CMSManage())
                {
                    var userBindInfo = manage.getUserBindInfo(accounttype, account);
                    if (userBindInfo != null)
                    {
                        return(this.getResult(Entity.Error.错误, "该账号已经绑定"));
                    }
                    else
                    {
                        manage.updateUserCode(this.userOnlineInfo.UserId, accounttype, oldaccount, account);
                        return(this.getResult(manage.Error, manage.Message));
                    }
                }
            }
            else
            {
                return(this.getResult(Entity.Error.错误, "验证码错误或已经过期"));
            }
        }
Beispiel #2
0
        public JsonResult getpassword(string account, string accounttype, string password, string verifycode)
        {
            string message = string.Empty;

            Entity.Error error = Entity.Error.请求成功;

            var mobilecode = Config.UserConfig.getVerifyCode(account);

            if (mobilecode != null && mobilecode.Code == verifycode && mobilecode.Deadline >= Config.SiteConfig.getLocalTime())
            {
                if (mobilecode.Account == account)
                {
                    using (var manage = new bitcms.Data.CMSManage())
                    {
                        var userBindInfo = manage.getUserBindInfo(accounttype, account);
                        if (userBindInfo != null && userBindInfo.UserId > 0)
                        {
                            manage.updatePassword(userBindInfo.UserId, Entity.passwordType.user, password);
                        }
                    }
                }
                else
                {
                    error   = Entity.Error.错误;
                    message = "验证账号和原账号不一致!";
                }
            }
            else
            {
                error   = Entity.Error.错误;
                message = "验证码错误或已经过期!";
            }
            return(this.getResult(error, message));
        }
Beispiel #3
0
        public ActionResult loginAccount(string account, string password, string accounttype, string key, string verifykey, int expires = 0)
        {
            if (this.userOnlineInfo.LoginVerifykey)
            {
                if (string.IsNullOrEmpty(key))
                {
                    key = "verifycode";
                }
                var code = Config.UserConfig.getVerifyCode(key);
                if (string.IsNullOrEmpty(verifykey) || code == null || !code.Code.Equals(verifykey.ToLower()))
                {
                    return(this.getResult(Entity.Error.错误, "验证码错误!", new { loginVerifykey = this.userOnlineInfo.LoginVerifykey }));
                }
            }
            using (var manage = new bitcms.Data.CMSManage())
            {
                if (string.IsNullOrEmpty(accounttype))
                {
                    if (Common.Utils.isMobile(account))
                    {
                        accounttype = "mobile";
                    }
                    else if (Common.Utils.isEmail(account))
                    {
                        accounttype = "email";
                    }
                }
                if (!string.IsNullOrEmpty(accounttype))
                {
                    var moduleInfo = manage.getModuleInfo(accounttype);
                    if (moduleInfo != null && moduleInfo.Enabled == 1)
                    {
                        var userBindInfo = manage.getUserBindInfo(accounttype, account);
                        if (userBindInfo != null)
                        {
                            if (manage.checkUserPassword(userBindInfo.UserId, password, Entity.passwordType.user))
                            {
                                this.userOnlineInfo.UnsafeVisitsNum = 0;
                                //设置会员在线
                                var userinfo = manage.getUserInfo(userBindInfo.UserId);
                                manage.updateLastLandDate(userinfo);

                                if (this.userOnlineInfo.IsOAuth)//更新授权登陆会员
                                {
                                    this.userOnlineInfo.UserBindInfo.UserId = userinfo.UserId;
                                    manage.updateUserBind(this.userOnlineInfo.UserBindInfo);
                                }

                                Config.UserConfig.setUserOnline(userinfo, expires);

                                //更改积分
                                manage.insertScoreLog(userinfo.UserId, "land");

                                return(this.getResult(Entity.Error.请求成功, "登录成功!"));
                            }
                            else
                            {
                                this.userOnlineInfo.UnsafeVisitsNum++;
                                return(this.getResult(Entity.Error.错误, "密码错误!", new { loginVerifykey = this.userOnlineInfo.LoginVerifykey }));
                            }
                        }
                        else
                        {
                            this.userOnlineInfo.UnsafeVisitsNum++;
                            return(this.getResult(Entity.Error.错误, "账号不存在!", new { loginVerifykey = this.userOnlineInfo.LoginVerifykey }));
                        }
                    }
                    else
                    {
                        return(this.getResult(Entity.Error.错误, "配置错误,请与网站管理员联系!", new { loginVerifykey = this.userOnlineInfo.LoginVerifykey }));
                    }
                }
                else
                {
                    //账号登录
                    return(checkUserPasword(account, password, expires));
                }
            }
        }