/// <summary> /// 明道登录 /// </summary> /// <returns></returns> public ActionResult MDLogin(string ReturnUrl) { if (string.IsNullOrEmpty(ReturnUrl)) { return(Redirect(OauthBusiness.GetAuthorizeUrl())); } else { return(Redirect(OauthBusiness.GetAuthorizeUrl() + "&state=" + ReturnUrl)); } }
//明道登录回掉 public ActionResult MDCallBack(string code) { string operateip = string.IsNullOrEmpty(Request.Headers.Get("X-Real-IP")) ? Request.UserHostAddress : Request.Headers["X-Real-IP"]; var user = OauthBusiness.GetMDUser(code); if (user.error_code <= 0) { var model = OrganizationBusiness.GetUserByMDUserID(user.user.id, user.user.project.id, operateip); //已注册云销账户 if (model != null) { //未注销 if (model.Status.Value != 9) { model.MDToken = user.user.token; if (string.IsNullOrEmpty(model.Avatar)) { model.Avatar = user.user.avatar; } Session["ClientManager"] = model; return(Redirect("/Home/Index")); } } else { int error = 0; bool isAdmin = MD.SDK.Entity.App.AppBusiness.IsAppAdmin(user.user.token, user.user.id, out error); if (isAdmin) { bool bl = AgentsBusiness.IsExistsMDProject(user.user.project.id); //明道网络未注册 if (!bl) { int result = 0; Clients clientModel = new Clients(); clientModel.CompanyName = user.user.project.name; clientModel.ContactName = user.user.name; clientModel.MobilePhone = user.user.mobile_phone; var clientid = ClientBusiness.InsertClient(clientModel, "", "", "", out result, user.user.email, user.user.id, user.user.project.id); if (!string.IsNullOrEmpty(clientid)) { var current = OrganizationBusiness.GetUserByMDUserID(user.user.id, user.user.project.id, operateip); current.MDToken = user.user.token; if (string.IsNullOrEmpty(current.Avatar)) { current.Avatar = user.user.avatar; } Session["ClientManager"] = current; return(Redirect("/Home/Index")); } } else { int result = 0; var current = OrganizationBusiness.CreateUser("", "", user.user.name, user.user.mobile_phone, user.user.email, "", "", "", "", "", "", "", "", user.user.id, user.user.project.id, 1, "", out result); if (current != null) { current.MDToken = user.user.token; if (string.IsNullOrEmpty(current.Avatar)) { current.Avatar = user.user.avatar; } Session["ClientManager"] = current; return(Redirect("/Home/Index")); } } } else { return(Redirect("/Home/InfoPage")); } } } return(Redirect("/Home/Login")); }
/// <summary> /// 明道登录 /// </summary> /// <returns></returns> public ActionResult MDLogin() { return(Redirect(OauthBusiness.GetAuthorizeUrl())); }