Exemplo n.º 1
0
        public async Task IsggCodes(string iscode, string url)
        {
            AjaxJson _ajv = new();

            if (Session.TryGetValue("IdentAdmin", out anmininfo))
            {
                GoogleAuthenticator authenticator = new(30, key : $"{anmininfo.BaseName}{anmininfo.ID}{8}");
                var mobileKey = authenticator.GenerateCode();
#if DEBUG
                mobileKey = iscode;
#endif
                if (!RoleAction.IsRepeatLogin(anmininfo.BaseName))
                {
                    _ajv.code = 105;
                    _ajv.msg  = "您的账号已登录,请联系超管!";
                }
                else if (iscode == mobileKey)
                {
                    if (anmininfo.IsIdent == 0)
                    {
                        FacadeManage.AideAdminFacade.SetBaseIsIdent(anmininfo.ID.ToString(), 1);//首次绑定成功后 更新绑定状态
                        //加入操作日志
                        AddBaseLog("Edit", "管理员绑定两步认证");
                    }

                    _ajv.code = 0;
                    _ajv.msg  = "验证成功!";
                    AddBaseLog("Login", "认证成功");//加入认证日志

                    //登录成功保存用户信息
                    RoleAction.Login(Session, anmininfo);
                    EditLoginMsg(anmininfo.ID);
                    Session.Remove("IdentAdmin");

                    url = string.IsNullOrWhiteSpace(url) ? "#/Welcome" : url.StringDecode();
                    _ajv.SetDataItem("url", url);
                }
                else
                {
                    _ajv.code = 1;
                    _ajv.msg  = "验证失败,请稍候再试!";
                }
            }
            else
            {
                _ajv.code = 1;
                _ajv.msg  = "请刷新界面重新登录!";
            }
            await JsonAsync(_ajv);
        }