Exemple #1
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));
                }
            }
        }