public string GetToken(string userName, string password) { string result = string.Empty; //验证通过 if (SmartAuthenticate.AuthenticateUser(userName, password, true, out result)) { return(result); } return(string.Empty); }
public void LoginOut(HttpContext context) { //响应者 HttpResponse Response = context.Response; //请求者 HttpRequest Request = context.Request; //往返路径 string returnUrl = Request["returnUrl"]; //如果没有回调链接,该SSO不起作用 if (string.IsNullOrEmpty(returnUrl)) { return; } else { //判断returnUrl是否为信任的Domain } if (Request["loginID"] != null) { //注销登录 SmartAuthenticate.SignOut(); //删除相关的SSOToken int count = SSOToken.SSOTokenList.RemoveAll(m => m.LoginID == Request["loginID"]); string result = "false"; if (count > 0) { result = "true"; } //拼接返回的url,参数中带Tip string spliter = returnUrl.Contains('?') ? "&" : "?"; //将TIP返回 returnUrl = returnUrl + spliter + "IsLoginOut=" + result; //跳转到访问该SSO的初始页面 Response.Redirect(returnUrl); } }
public void Login(HttpContext context) { //响应者 HttpResponse Response = context.Response; //请求者 HttpRequest Request = context.Request; //往返路径 string returnUrl = Request["returnUrl"]; //如果没有回调链接,该SSO不起作用 if (string.IsNullOrEmpty(returnUrl)) { return; } else { //判断returnUrl是否为信任的Domain } if (Request["UserName"] != "" && Request["password"] != "") { var pp = context.User.Identity.Name; string userName = Request["UserName"]; string passWord = Request["password"]; bool result = SmartAuthenticate.AuthenticateUser(userName, passWord, true); //SSOToken token = null; ////判断当前是否登录() //if (SmartAuthenticate.LoginUser != null)//未登录(生成token【携带用户信息】,并加入到集合里去) //{ // SmartAuthenticate.LoginUser.UserName = userName; // token = TokenManage.SetToken(context.Session.SessionID); //} SSOToken token = null; //判断当前是否登录() if (!string.IsNullOrEmpty(userName))//未登录(生成token【携带用户信息】,并加入到集合里去) { //SmartAuthenticate.LoginUser.UserName = userName; token = TokenManage.SetToken(context.Session.SessionID, userName, passWord); } //拼接返回的url,参数中带Tip string spliter = returnUrl.Contains('?') ? "&" : "?"; if (token != null) { //将TIP返回 returnUrl = returnUrl + spliter + "token=" + token.ID + "&IsSuccessed=" + "true"; } else { //将TIP返回 returnUrl = returnUrl + spliter + "&IsSuccessed=" + "false"; } string callback = context.Request["jsoncallback"]; Response.Write(callback + "({\"result\":\"" + token.ID + "\"})"); //跳转到访问该SSO的初始页面 //Response.Redirect(returnUrl); } }