protected RedirectResult UserLoginedAndRedirect(Miaow.Service.SSO.Entity.User user) { #region user first login var tempOnlineUser = Miaow.Service.SSO.WebService.OnLineUserService .OnLineUserList.Where(e => e.username == user.username && e.id == user.id) .FirstOrDefault(); if (tempOnlineUser == null) { var onlineUser = new Miaow.Service.SSO.Entity.OnlineUser() { Activity = user.Activity, DepartmentID = user.DepartmentID, Email = user.Email, EmployeeID = user.EmployeeID, id = user.id, lastloginip = user.lastloginip, lastlogintime = user.lastlogintime, LoginDomain = user.LoginDomain, LoginIpAddress = user.LoginIpAddress, LoginTime = System.DateTime.Now, logintimes = user.logintimes, password = user.password, Phone = user.Phone, roleid = user.roleid, sex = user.sex, style = user.style, truename = user.truename, UserGuid = user.UserGuid, userid = user.userid, username = user.username, UserType = user.UserType }; Miaow.Service.SSO.WebService.OnLineUserService.OnLineUserList.Add(onlineUser); } #endregion //add session 这里的session用法,要和子站点统一,管理好时间 Miaow.Infrastructure.Crosscutting.Function.SessionHelper.Add( Miaow.Infrastructure.Crosscutting.Comm.Service.ConstService.SessionNameCurrentUser, user, Miaow.Infrastructure.Crosscutting.Comm.Service.ConstService.SessionExpires); //添加 Cookie 一边以其它业务网站能够访问 Miaow.Infrastructure.Crosscutting.Comm.Service.SsoService.SendSsoUserLoginedCookie(); //添加日志记录 #region buileder secutity token Miaow.Service.SSO.Entity.SecurityToken securityToken = new Entity.SecurityToken() { CreateTime = System.DateTime.Now, TokenId = Miaow.Infrastructure.Crosscutting.Comm.Service.SsoService.BuilderTokenId(), IsValid = false, User = user }; Miaow.Service.SSO.WebService.SecurityTokenService.SecurityTokenList.Add(securityToken); #endregion //返回 var url = this.GetReturnUrl(securityToken.TokenId); return Redirect(url); }
protected RedirectResult UserLoginedAndRedirect(iPow.Service.SSO.Entity.User user) { #region user first login var tempOnlineUser = iPow.Service.SSO.WebService.OnLineUserService .OnLineUserList.Where(e => e.username == user.username && e.id == user.id) .FirstOrDefault(); if (tempOnlineUser == null) { var onlineUser = new iPow.Service.SSO.Entity.OnlineUser() { Activity = user.Activity, DepartmentID = user.DepartmentID, Email = user.Email, EmployeeID = user.EmployeeID, id = user.id, lastloginip = user.lastloginip, lastlogintime = user.lastlogintime, LoginDomain = user.LoginDomain, LoginIpAddress = user.LoginIpAddress, LoginTime = System.DateTime.Now, logintimes = user.logintimes, password = user.password, Phone = user.Phone, roleid = user.roleid, sex = user.sex, style = user.style, truename = user.truename, UserGuid = user.UserGuid, userid = user.userid, username = user.username, UserType = user.UserType }; iPow.Service.SSO.WebService.OnLineUserService.OnLineUserList.Add(onlineUser); } #endregion //add session 这里的session用法,要和子站点统一,管理好时间 iPow.Infrastructure.Crosscutting.Function.SessionHelper.Add( iPow.Infrastructure.Crosscutting.Comm.Service.ConstService.SessionNameCurrentUser, user, iPow.Infrastructure.Crosscutting.Comm.Service.ConstService.SessionExpires); //添加 Cookie 一边以其它业务网站能够访问 iPow.Infrastructure.Crosscutting.Comm.Service.SsoService.SendSsoUserLoginedCookie(); //添加日志记录 #region buileder secutity token iPow.Service.SSO.Entity.SecurityToken securityToken = new Entity.SecurityToken() { CreateTime = System.DateTime.Now, TokenId = iPow.Infrastructure.Crosscutting.Comm.Service.SsoService.BuilderTokenId(), IsValid = false, User = user }; iPow.Service.SSO.WebService.SecurityTokenService.SecurityTokenList.Add(securityToken); #endregion //返回 var url = this.GetReturnUrl(securityToken.TokenId); return(Redirect(url)); }
/// <summary> /// 用户已登录 /// </summary> /// <param name="user">The user.</param> /// <param name="returnUrl">The return URL.</param> /// <returns></returns> private RedirectResult UserLogined(Miaow.Service.SSO.Entity.User user, string returnUrl) { #region user first login var tempOnlineUser = Miaow.Service.SSO.WebService.OnLineUserService .OnLineUserList.Where(e => e.username == user.username && e.id == user.id) .FirstOrDefault(); if (tempOnlineUser == null) { var onlineUser = new Miaow.Service.SSO.Entity.OnlineUser() { Activity = user.Activity, DepartmentID = user.DepartmentID, Email = user.Email, EmployeeID = user.EmployeeID, id = user.id, lastloginip = user.lastloginip, lastlogintime = user.lastlogintime, LoginDomain = user.LoginDomain, LoginIpAddress = user.LoginIpAddress, LoginTime = System.DateTime.Now, logintimes = user.logintimes, password = user.password, Phone = user.Phone, roleid = user.roleid, sex = user.sex, style = user.style, truename = user.truename, UserGuid = user.UserGuid, userid = user.userid, username = user.username, UserType = user.UserType }; Miaow.Service.SSO.WebService.OnLineUserService.OnLineUserList.Add(onlineUser); } #endregion #region buileder secutity token Miaow.Service.SSO.Entity.SecurityToken securityToken = new Entity.SecurityToken() { CreateTime = System.DateTime.Now, TokenId = Miaow.Infrastructure.Crosscutting.Comm.Service.SsoService.BuilderTokenId(), IsValid = false, User = user }; Miaow.Service.SSO.WebService.SecurityTokenService.SecurityTokenList.Add(securityToken); #endregion //add session 这里的session用法,要和子站点统一,管理好时间 Miaow.Infrastructure.Crosscutting.Function.SessionHelper.Add( Miaow.Infrastructure.Crosscutting.Comm.Service.ConstService.SessionNameCurrentUser, user, Miaow.Infrastructure.Crosscutting.Comm.Service.ConstService.SessionExpires); if (string.IsNullOrWhiteSpace(returnUrl)) { return Redirect("/"); } string splitStr = returnUrl.Contains("?") ? "&" : "?"; string returnFormat = "{0}{1}" + Miaow.Infrastructure.Crosscutting.Comm.Service.ConstService.UrlParaToken + "={2}"; string tokenStr = securityToken.TokenId; var redirectUrl = string.Format(returnFormat, returnUrl, splitStr, tokenStr); return Redirect(redirectUrl); }
/// <summary> /// 用户已登录 /// </summary> /// <param name="user">The user.</param> /// <param name="returnUrl">The return URL.</param> /// <returns></returns> private RedirectResult UserLogined(iPow.Service.SSO.Entity.User user, string returnUrl) { #region user first login var tempOnlineUser = iPow.Service.SSO.WebService.OnLineUserService .OnLineUserList.Where(e => e.username == user.username && e.id == user.id) .FirstOrDefault(); if (tempOnlineUser == null) { var onlineUser = new iPow.Service.SSO.Entity.OnlineUser() { Activity = user.Activity, DepartmentID = user.DepartmentID, Email = user.Email, EmployeeID = user.EmployeeID, id = user.id, lastloginip = user.lastloginip, lastlogintime = user.lastlogintime, LoginDomain = user.LoginDomain, LoginIpAddress = user.LoginIpAddress, LoginTime = System.DateTime.Now, logintimes = user.logintimes, password = user.password, Phone = user.Phone, roleid = user.roleid, sex = user.sex, style = user.style, truename = user.truename, UserGuid = user.UserGuid, userid = user.userid, username = user.username, UserType = user.UserType }; iPow.Service.SSO.WebService.OnLineUserService.OnLineUserList.Add(onlineUser); } #endregion #region buileder secutity token iPow.Service.SSO.Entity.SecurityToken securityToken = new Entity.SecurityToken() { CreateTime = System.DateTime.Now, TokenId = iPow.Infrastructure.Crosscutting.Comm.Service.SsoService.BuilderTokenId(), IsValid = false, User = user }; iPow.Service.SSO.WebService.SecurityTokenService.SecurityTokenList.Add(securityToken); #endregion //add session 这里的session用法,要和子站点统一,管理好时间 iPow.Infrastructure.Crosscutting.Function.SessionHelper.Add( iPow.Infrastructure.Crosscutting.Comm.Service.ConstService.SessionNameCurrentUser, user, iPow.Infrastructure.Crosscutting.Comm.Service.ConstService.SessionExpires); if (string.IsNullOrWhiteSpace(returnUrl)) { return(Redirect("/")); } string splitStr = returnUrl.Contains("?") ? "&" : "?"; string returnFormat = "{0}{1}" + iPow.Infrastructure.Crosscutting.Comm.Service.ConstService.UrlParaToken + "={2}"; string tokenStr = securityToken.TokenId; var redirectUrl = string.Format(returnFormat, returnUrl, splitStr, tokenStr); return(Redirect(redirectUrl)); }