예제 #1
0
        /// <summary>
        /// 提交新账户,如果不存在,则添加,如果存在则修改
        /// </summary>
        /// <param name="name">账户名</param>
        /// <param name="userid">用户Id</param>
        /// <param name="flags">账户标示</param>
        /// <param name="accountType">账户类型</param>
        /// <returns></returns>
        public static Account Post(string name, Guid userid, UMC.Security.UserFlags flags, int accountType)
        {
            var entity = UMC.Data.Database.Instance().ObjectEntity <UMC.Data.Entities.Account>();

            var acc = new UMC.Data.Entities.Account
            {
                Name  = name,
                Flags = flags
            };

            entity.Where.Reset().And().Equal(new UMC.Data.Entities.Account
            {
                Type    = accountType,
                user_id = userid
            });
            var acc2 = entity.Single();

            if (acc2 == null)
            {
                acc.user_id = userid;
                acc.Type    = accountType;
                entity.Insert(acc);
                return(new Account(acc));
            }
            else
            {
                entity.Update(acc);
                acc2.Name  = acc.Name;
                acc2.Flags = acc.Flags;
                return(new Account(acc2));
            }
        }
예제 #2
0
 private Account(UMC.Data.Entities.Account acc)
 {
     this.Name    = acc.Name;
     this.Flags   = acc.Flags ?? UMC.Security.UserFlags.Normal;
     this.ForId   = acc.ForId;
     this.user_id = acc.user_id.Value;
     this.Type    = acc.Type ?? 0;
     this.Items   = UMC.Data.JSON.Deserialize <Hashtable>(acc.ConfigData) ?? new Hashtable();
 }
예제 #3
0
        void DD(String code, Guid projectId)
        {
            var accessToken = SubjectDingtalkActivity.AccessToken(projectId);
            var url         = String.Format("https://oapi.dingtalk.com/user/getuserinfo?access_token={1}&code={0}", code, accessToken.AccessToken);

            System.Net.Http.HttpClient httpClient = new System.Net.Http.HttpClient();
            var data = UMC.Data.JSON.Deserialize(httpClient.GetStringAsync(url)
                                                 .Result) as Hashtable;

            if (data.ContainsKey("userid"))
            {
                var userId = data["userid"] as string;

                var url2   = String.Format("https://oapi.dingtalk.com/user/get?access_token={1}&userid={0}", userId, accessToken.AccessToken);
                var data2  = UMC.Data.JSON.Deserialize(httpClient.GetStringAsync(url2).Result) as Hashtable;
                var mgurl  = data2["avatar"] as string;
                var mobile = data2["mobile"] as string;
                if (String.IsNullOrEmpty(mobile))
                {
                    Utility.Debug("login", data, data2);
                    this.Prompt("未开通获取手机号码权限,请联系钉钉管理员");
                }

                var open = new UMC.Data.Entities.Account()
                {
                    Type = UMC.Security.Account.MOBILE_ACCOUNT_KEY,
                    Name = mobile
                };

                Security.Account.GetRelation(open);


                var nickname = data2["name"] as string;
                var user     = UMC.Security.Membership.Instance().Identity(open.user_id.Value);
                if (user == null)
                {
                    user = UMC.Security.Membership.Instance().CreateUser(open.user_id.Value, "@" + mobile, Utility.Guid(open.user_id.Value), nickname);
                }
                UMC.Security.AccessToken.Login(user
                                               , UMC.Security.AccessToken.Token.Value, 0, "DingTalkPC", false).Put("DingTalk-Setting", Utility.Guid(accessToken.Id.Value))
                .Put("DingTalk-User-Id", userId).Commit();


                if (String.IsNullOrEmpty(mgurl) == false)
                {
                    UMC.Data.WebResource.Instance().Transfer(new Uri(mgurl), open.user_id.Value, 1);
                }

                this.Context.Send("User", true);
            }
            else
            {
                Utility.Debug("login", data);
                this.Prompt("未获得钉钉信息");
            }
        }
예제 #4
0
        /// <summary>
        /// 更改数据配置
        /// </summary>
        public void Commit()
        {
            var entity = UMC.Data.Database.Instance().ObjectEntity <UMC.Data.Entities.Account>();

            entity.Where.And().Equal(new UMC.Data.Entities.Account {
                user_id = this.user_id, Type = this.Type
            });
            var data = new UMC.Data.Entities.Account {
                ConfigData = Data.JSON.Serialize(this.Items), ForId = this.ForId, Name = this.Name
            };

            if (entity.Update(data) == 0)
            {
                data.user_id = this.user_id;
                data.Name    = this.Name;
                data.Type    = this.Type;
                entity.Insert(data);
            }
        }
예제 #5
0
        public override void ProcessActivity(WebRequest request, WebResponse response)
        {
            var user = Web.UIFormDialog.AsyncDialog("Register", d =>
            {
                if (request.SendValues != null && request.SendValues.Count > 0)
                {
                    return(this.DialogValue(request.SendValues));
                }

                var u = new UMC.Data.Entities.User {
                    Username = String.Empty
                };

                var dialog   = new Web.UIFormDialog();
                dialog.Title = "账户注册";
                dialog.AddText("昵称", "Alias", u.Alias);

                dialog.AddText("手机号码", "Username", u.Username);
                dialog.AddVerify("验证码", "VerifyCode", "您收到的验证码").Put("For", "Username").Put("To", "Mobile")
                .Put("Command", request.Command).Put("Model", request.Model);

                if (request.IsApp == false)
                {
                    dialog.AddPassword("密码", "Password", false);
                    dialog.AddPassword("确认密码", "NewPassword2", false).Put("placeholder", "再输入一次密码").Put("ForName", "Password");
                }
                dialog.Submit("确认注册", request, "register");
                return(dialog);
            });

            if (user.ContainsKey("Mobile"))
            {
                var mobile  = user["Mobile"];
                var account = Data.Database.Instance().ObjectEntity <UMC.Data.Entities.Account>()
                              .Where.And().Equal(new UMC.Data.Entities.Account
                {
                    Name = mobile,
                    Type = UMC.Security.Account.MOBILE_ACCOUNT_KEY
                }).Entities.Single();
                if (account != null)
                {
                    this.Prompt("此手机号码已经注册,你可直接登录");
                }
                this.SendMobileCode(mobile);
                this.Prompt("验证码已发送", false);
                this.Context.Send(new UMC.Web.WebMeta().UIEvent("VerifyCode", this.AsyncDialog("UI", "none"), new UMC.Web.WebMeta().Put("text", "验证码已发送")), true);
            }
            var username = user["Username"];

            if (user.ContainsKey("VerifyCode"))
            {
                var VerifyCode = user["VerifyCode"];
                var session    = new UMC.Configuration.Session <Hashtable>(username);
                if (session.Value != null)
                {
                    var code = session.Value["Code"] as string;
                    if (String.Equals(code, VerifyCode) == false)
                    {
                        this.Prompt("请输入正确的验证码");
                    }
                }
                else
                {
                    this.Prompt("请输入正确的验证码");
                }
            }


            var entity = Data.Database.Instance().ObjectEntity <UMC.Data.Entities.Account>();

            UMC.Data.Entities.Account ac = new UMC.Data.Entities.Account {
                Name = username
            };
            if (Data.Utility.IsEmail(username))
            {
                ac.Type = UMC.Security.Account.EMAIL_ACCOUNT_KEY;
                entity.Where.And().Equal(ac);
            }
            else if (Data.Utility.IsPhone(username))
            {
                ac.Type = UMC.Security.Account.MOBILE_ACCOUNT_KEY;
                entity.Where.And().Equal(ac);
            }
            if (ac.Type.HasValue == false)
            {
                this.Prompt("只支持手机号注册");
            }
            if (entity.Count() > 0)
            {
                switch (ac.Type.Value)
                {
                case UMC.Security.Account.EMAIL_ACCOUNT_KEY:
                    this.Prompt("此邮箱已经注册");
                    break;

                default:
                    this.Prompt("此手机号已经注册");
                    break;
                }
            }
            var passwork     = user["Password"];
            var NewPassword2 = user["NewPassword2"];

            if (String.IsNullOrEmpty(NewPassword2) == false)
            {
                if (String.Equals(passwork, NewPassword2) == false)
                {
                    this.Prompt("两次密码不相同,请确认密码");
                }
            }
            var Alias = user["Alias"] ?? username;
            var uM    = UMC.Security.Membership.Instance();
            var uid   = uM.CreateUser(username, passwork ?? username, Alias);

            if (uid != Guid.Empty)
            {
                if (user.ContainsKey("VerifyCode"))
                {
                    UMC.Security.Account.Post(ac.Name, uid, UMC.Security.UserFlags.Normal, ac.Type.Value);
                }
                else
                {
                    UMC.Security.Account.Post(ac.Name, uid, UMC.Security.UserFlags.UnVerification, ac.Type.Value);
                }
                var iden = uM.Identity(username);

                UMC.Security.AccessToken.Login(iden, UMC.Security.AccessToken.Token.Value, request.IsApp ? "App" : "Client", true);

                this.Context.Send(new UMC.Web.WebMeta().Put("type", "register"), false);
                this.Context.Send(new UMC.Web.WebMeta().Put("type", "User"), false);
                this.Prompt("注册成功");
            }
            else
            {
                this.Prompt("已经存在这个用户");
            }
        }
예제 #6
0
 public static Account Create(UMC.Data.Entities.Account acc)
 {
     return(new Account(acc));
 }
예제 #7
0
        public override void ProcessActivity(WebRequest request, WebResponse response)
        {
            var username = Web.UIDialog.AsyncDialog("Username", d =>
            {
                var fd   = new UMC.Web.UIFormDialog();
                fd.Title = "找回密码";
                fd.AddText("", "Username").Put("placeholder", "手机号码或邮箱");

                fd.Submit("下一步", request, "Forget");
                return(fd);
            });
            var entity = Data.Database.Instance().ObjectEntity <UMC.Data.Entities.Account>();

            UMC.Data.Entities.Account ac = new UMC.Data.Entities.Account {
                Name = username
            };
            if (Data.Utility.IsEmail(username))
            {
                ac.Type = UMC.Security.Account.EMAIL_ACCOUNT_KEY;
                entity.Where.And().Equal(ac);
            }
            else if (Data.Utility.IsPhone(username))
            {
                ac.Type = UMC.Security.Account.MOBILE_ACCOUNT_KEY;
                entity.Where.And().Equal(ac);
            }
            if (ac.Type.HasValue == false)
            {
                this.Prompt("只支持手机号和邮箱找回密码");
            }
            var acct = entity.Single();

            if (acct == null)
            {
                switch (ac.Type.Value)
                {
                case UMC.Security.Account.EMAIL_ACCOUNT_KEY:
                    this.Prompt("没有找到此邮箱绑定账户");
                    break;

                default:
                    this.Prompt("没有找到此手机号绑定账户");
                    break;
                }
            }
            var Code = UMC.Web.UIDialog.AsyncDialog("Code", g =>
            {
                var ts = ac.Type.Value == UMC.Security.Account.EMAIL_ACCOUNT_KEY ? "邮箱" : "手机";
                var fd = new UMC.Web.UIFormDialog();
                fd.AddTextValue().Put(ts, username);

                fd.AddVerify("验证码", "Code", String.Format("{0}收到的验证码", ts))
                .Command(request.Model, request.Command, new UMC.Web.WebMeta().Put("Username", username).Put("Code", "Reset"));
                fd.Title = "验证" + ts;
                fd.Submit("验证", request, "Password");
                this.Context.Send(new UMC.Web.WebMeta().Put("type", "Forget"), false);

                return(fd);
            });

            if (String.Equals(Code, "Reset"))
            {
                ;
                if (this.Send(username, UMC.Data.Reflection.GetDataProvider("account", "Forget")))
                {
                    this.Prompt("验证码已经发送,请注意查收", false);
                    this.Context.Send(new UMC.Web.WebMeta().UIEvent("VerifyCode", this.AsyncDialog("UI", "none"), new UMC.Web.WebMeta().Put("text", "验证码已发送")), true);
                }
                else
                {
                    switch (ac.Type.Value)
                    {
                    case UMC.Security.Account.EMAIL_ACCOUNT_KEY:
                        this.Prompt("没有找到此邮箱绑定账户");
                        break;

                    default:
                        this.Prompt("没有找到此手机号绑定账户");
                        break;
                    }
                }
            }
            var account    = Account.Create(acct);
            var VerifyCode = account.Items[Account.KEY_VERIFY_FIELD] as string;

            if (String.Equals(VerifyCode, Code, StringComparison.CurrentCultureIgnoreCase))
            {
                WebMeta print = new UMC.Web.WebMeta();
                print["AccountType"] = acct.Type.ToString();
                print["VerifyCode"]  = Code;
                print["user_id"]     = acct.user_id.ToString();

                this.Context.Send(new UMC.Web.WebMeta().Put("type", "Forget"), false);
                response.Redirect(request.Model, "Password", print, true);
            }
            else
            {
                this.Prompt("您输入的验证码错误");
            }
        }
        public override void ProcessActivity(WebRequest request, WebResponse response)
        {
            var type = this.AsyncDialog("type", t => this.DialogValue("auto"));

            switch (type)
            {
            case "wx":
                this.Context.Send(new UMC.Web.WebMeta().Put("type", "login.weixin"), true);
                break;

            case "qq":
                this.Context.Send(new UMC.Web.WebMeta().Put("type", "login.qq"), true);
                break;
            }
            var user = Web.UIFormDialog.AsyncDialog("Login", d =>
            {
                if (request.SendValues != null && request.SendValues.Count > 0)
                {
                    return(this.DialogValue(request.SendValues));
                }
                if (request.Url.Query.Contains("_v=Sub"))
                {
                    this.Context.Send("Login", true);
                }

                //   var u = new UMC.Data.Entities.User { Username = String.Empty };


                var dialog   = new Web.UIFormDialog();
                dialog.Title = "登录";
                switch (type)
                {
                default:
                case "User":
                    this.Context.Send("LoginChange", false);
                    {
                        dialog.AddText("用户名", "Username", String.Empty).Put("placeholder", "用户名/手机/邮箱");

                        dialog.AddPassword("用户密码", "Password", String.Empty);

                        dialog.Submit("登录", request, "User", "LoginChange");
                        var uidesc = new UMC.Web.UI.UIDesc(new WebMeta().Put("eula", "用户协议").Put("private", "隐私政策"));
                        uidesc.Desc("登录即同意“{eula}”和“{private}”");
                        uidesc.Style.AlignCenter();
                        uidesc.Style.Color(0x888).Size(14).Height(34);
                        uidesc.Style.Name("eula").Color(0x3194d0).Click(new UIClick("365lu/provision/eula").Send("Subject", "UIData"));
                        uidesc.Style.Name("private").Color(0x3194d0).Click(new UIClick("365lu/provision/private").Send("Subject", "UIData"));
                        dialog.Add(uidesc);
                        dialog.AddUIIcon("\uf2c1", "免密登录").Command(request.Model, request.Command, "Mobile");
                        dialog.AddUIIcon("\uf1c6", "忘记密码").Put("Model", request.Model).Put("Command", "Forget");
                        dialog.AddUIIcon("\uf234", "注册新用户").Put("Model", request.Model).Put("Command", "Register");
                    }
                    break;

                case "Mobile":
                    this.Context.Send("LoginChange", false);
                    {
                        dialog.AddText("手机号码", "Username", String.Empty).Put("placeholder", "注册的手机号码");

                        dialog.AddVerify("验证码", "VerifyCode", "您收到的验证码").Put("For", "Username").Put("To", "Mobile")
                        .Put("Command", request.Command).Put("Model", request.Model);
                        dialog.Submit("登录", request, "User", "LoginChange");

                        var uidesc = new UMC.Web.UI.UIDesc(new WebMeta().Put("eula", "用户协议").Put("private", "隐私政策"));
                        uidesc.Desc("登录即同意“{eula}”和“{private}”");
                        uidesc.Style.AlignCenter();
                        uidesc.Style.Color(0x888).Size(14).Height(34);
                        uidesc.Style.Name("eula").Color(0x3194d0).Click(new UIClick("365lu/provision/eula").Send("Subject", "UIData"));
                        uidesc.Style.Name("private").Color(0x3194d0).Click(new UIClick("365lu/provision/private").Send("Subject", "UIData"));
                        dialog.Add(uidesc);
                        dialog.AddUIIcon("\uf13e", "密码登录").Command(request.Model, request.Command, "User");
                        dialog.AddUIIcon("\uf234", "注册新用户").Command(request.Model, "Register");    //.Put("Model", request.Model).Put("Command", "Register");
                    }
                    break;
                }

                return(dialog);
            });

            if (user.ContainsKey("Mobile"))
            {
                var mobile = user["Mobile"];

                var account = Data.Database.Instance().ObjectEntity <UMC.Data.Entities.Account>()
                              .Where.And().Equal(new UMC.Data.Entities.Account
                {
                    Name = mobile,
                    Type = UMC.Security.Account.MOBILE_ACCOUNT_KEY
                }).Entities.Single();
                if (account == null)
                {
                    this.Prompt("不存在此账户");
                }


                this.SendMobileCode(mobile);
                this.Prompt("验证码已发送", false);
                this.Context.Send(new UMC.Web.WebMeta().UIEvent("VerifyCode", this.AsyncDialog("UI", "none"), new UMC.Web.WebMeta().Put("text", "验证码已发送")), true);
            }

            var username = user["Username"];

            var userManager = UMC.Security.Membership.Instance();

            if (user.ContainsKey("VerifyCode"))
            {
                var VerifyCode = user["VerifyCode"];
                var session    = new UMC.Configuration.Session <Hashtable>(username);
                if (session.Value != null)
                {
                    var code = session.Value["Code"] as string;
                    if (String.Equals(code, VerifyCode) == false)
                    {
                        this.Prompt("请输入正确的验证码");
                    }
                }
                else
                {
                    this.Prompt("请输入正确的验证码");
                }
                var entity = Data.Database.Instance().ObjectEntity <UMC.Data.Entities.Account>();
                UMC.Data.Entities.Account ac = new UMC.Data.Entities.Account
                {
                    Name = username,
                    Type = UMC.Security.Account.MOBILE_ACCOUNT_KEY
                };

                var eData = entity.Where.And().Equal(ac).Entities.Single();
                if (eData == null)
                {
                    this.Prompt("无此号码关联的账户,请注册");
                }
                else
                {
                    var iden = userManager.Identity(eData.user_id.Value);
                    //System.Security.Principal.IPrincipal p = iden;
                    //if (p.IsInRole(UMC.Security.Membership.UserRole))
                    //{
                    //    this.Prompt("您是内部账户,不可从此入口登录");
                    //}


                    UMC.Security.AccessToken.Login(iden, UMC.Security.AccessToken.Token.Value, request.IsApp ? "App" : "Client", true);
                    this.Context.Send("User", true);
                }
            }
            else
            {
                var passwork = user["Password"];

                var maxTimes = 5;
                UMC.Security.Identity identity = null;
                if (UMC.Data.Utility.IsPhone(username))
                {
                    identity = userManager.Identity(username, Security.Account.MOBILE_ACCOUNT_KEY) ?? userManager.Identity(username);
                }
                else if (username.IndexOf('@') > -1)
                {
                    identity = userManager.Identity(username, Security.Account.EMAIL_ACCOUNT_KEY) ?? userManager.Identity(username);
                }
                else
                {
                    identity = userManager.Identity(username);
                }
                if (identity == null)
                {
                    this.Prompt("用户不存在,请确认用户名");
                }
                var times = userManager.Password(identity.Name, passwork, maxTimes);
                switch (times)
                {
                case 0:
                    var iden = userManager.Identity(username);
                    //System.Security.Principal.IPrincipal p = iden;
                    //if (p.IsInRole(UMC.Security.Membership.UserRole))
                    //{
                    //    this.Prompt("您是内部账户,不可从此入口登录");
                    //}


                    UMC.Security.AccessToken.Login(iden, UMC.Security.AccessToken.Token.Value, request.IsApp ? "App" : "Client", true);


                    this.Context.Send("User", true);



                    break;

                case -2:
                    this.Prompt("您的用户已经锁定,请过后登录");
                    break;

                case -1:
                    this.Prompt("您的用户不存在,请确定用户名");

                    break;

                default:
                    this.Prompt(String.Format("您的用户和密码不正确,您还有{0}次机会", maxTimes - times));

                    break;
                }
            }
        }
예제 #9
0
        public override void ProcessActivity(WebRequest request, WebResponse response)
        {
            var type = this.AsyncDialog("type", t => this.DialogValue("auto"));

            switch (type)
            {
            case "wx":
                this.Context.Send(new UMC.Web.WebMeta().Put("type", "login.weixin"), true);
                break;

            case "qq":
                this.Context.Send(new UMC.Web.WebMeta().Put("type", "login.qq"), true);
                break;
            }
            var user = Web.UIFormDialog.AsyncDialog("Login", d =>
            {
                var u = new UMC.Data.Entities.User {
                    Username = String.Empty
                };


                var dialog   = new Web.UIFormDialog();
                dialog.Title = "账户登录";
                if (request.IsApp)
                {
                    dialog.AddText("手机号码", "Username", u.Username).Put("placeholder", "手机");

                    dialog.AddVerify("验证码", "VerifyCode", "您收到的验证码").Put("For", "Username").Put("To", "Mobile")
                    .Put("Command", request.Command).Put("Model", request.Model);
                    dialog.Submit("登录", request, "User");
                    dialog.AddUIIcon("\uf234", "注册新用户").Put("Model", request.Model).Put("Command", "Register");
                }
                else
                {
                    dialog.AddText("用户名", "Username", u.Username).Put("placeholder", "手机/邮箱");

                    dialog.AddPassword("用户密码", "Password", String.Empty);
                    dialog.Submit("登录", request, "User");
                    dialog.AddUIIcon("\uf1c6", "忘记密码").Put("Model", request.Model).Put("Command", "Forget");
                    dialog.AddUIIcon("\uf234", "注册新用户").Put("Model", request.Model).Put("Command", "Register");
                }
                return(dialog);
            });

            if (user.ContainsKey("Mobile"))
            {
                var mobile = user["Mobile"];

                var account = Data.Database.Instance().ObjectEntity <UMC.Data.Entities.Account>()
                              .Where.And().Equal(new UMC.Data.Entities.Account
                {
                    Name = mobile,
                    Type = UMC.Security.Account.MOBILE_ACCOUNT_KEY
                }).Entities.Single();
                if (account == null)
                {
                    this.Prompt("不存在此账户");
                }


                this.SendMobileCode(mobile);
                this.Prompt("验证码已发送", false);
                this.Context.Send(new UMC.Web.WebMeta().UIEvent("VerifyCode", this.AsyncDialog("UI", "none"), new UMC.Web.WebMeta().Put("text", "验证码已发送")), true);
            }

            var username = user["Username"];

            var userManager = UMC.Security.Membership.Instance();

            if (user.ContainsKey("VerifyCode"))
            {
                var VerifyCode = user["VerifyCode"];
                var session    = new UMC.Configuration.Session <Hashtable>(username);
                if (session.Value != null)
                {
                    var code = session.Value["Code"] as string;
                    if (String.Equals(code, VerifyCode) == false)
                    {
                        this.Prompt("请输入正确的验证码");
                    }
                }
                else
                {
                    this.Prompt("请输入正确的验证码");
                }
                var entity = Data.Database.Instance().ObjectEntity <UMC.Data.Entities.Account>();
                UMC.Data.Entities.Account ac = new UMC.Data.Entities.Account
                {
                    Name = username,
                    Type = UMC.Security.Account.MOBILE_ACCOUNT_KEY
                };

                var eData = entity.Where.And().Equal(ac).Entities.Single();
                if (eData == null)
                {
                    this.Prompt("无此号码关联的账户,请注册");
                }
                else
                {
                    var iden = userManager.Identity(eData.user_id.Value);
                    System.Security.Principal.IPrincipal p = iden;
                    if (p.IsInRole(UMC.Security.Membership.UserRole))
                    {
                        this.Prompt("您是内部账户,不可从此入口登录");
                    }


                    UMC.Security.AccessToken.Login(iden, UMC.Security.AccessToken.Token.Value, request.IsApp ? "App" : "Client", true);
                    this.Context.Send("User", true);
                }
            }
            else
            {
                var passwork = user["Password"];

                var maxTimes = 5;
                UMC.Security.Identity identity = null;
                if (UMC.Data.Utility.IsPhone(username))
                {
                    identity = userManager.Identity(username, Security.Account.MOBILE_ACCOUNT_KEY) ?? userManager.Identity(username);
                }
                else if (username.IndexOf('@') > -1)
                {
                    identity = userManager.Identity(username, Security.Account.EMAIL_ACCOUNT_KEY) ?? userManager.Identity(username);
                }
                else
                {
                    identity = userManager.Identity(username);
                }
                if (identity == null)
                {
                    this.Prompt("用户不存在,请确认用户名");
                }
                var times = userManager.Password(identity.Name, passwork, maxTimes);
                switch (times)
                {
                case 0:
                    var iden = userManager.Identity(username);
                    System.Security.Principal.IPrincipal p = iden;
                    if (p.IsInRole(UMC.Security.Membership.UserRole))
                    {
                        this.Prompt("您是内部账户,不可从此入口登录");
                    }


                    UMC.Security.AccessToken.Login(iden, UMC.Security.AccessToken.Token.Value, request.IsApp ? "App" : "Client", true);


                    this.Context.Send("User", true);



                    break;

                case -2:
                    this.Prompt("您的用户已经锁定,请过后登录");
                    break;

                case -1:
                    this.Prompt("您的用户不存在,请确定用户名");

                    break;

                default:
                    this.Prompt(String.Format("您的用户和密码不正确,您还有{0}次机会", maxTimes - times));

                    break;
                }
            }
        }