public MobileSession() { WebCookies.Add(new Cookie("mobileClientVersion", ClientVersion, "/", CommunityCookieDomain)); WebCookies.Add(new Cookie("mobileClient", ClientName, "/", CommunityCookieDomain)); }
/// <summary> /// 授权事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public static void AuthenticateRequestEvent <TPrincipal, TIdentity>(object sender, EventArgs e) where TIdentity : class where TPrincipal : IPrincipal { var context = new HttpContextWrapper(HttpContext.Current); var webCookies = new WebCookies(context); if (context.Request.Url != null) { var pathAndQuery = context.Request.Url.PathAndQuery.ToLower(); if (_ignorePaths.Any(pathAndQuery.StartsWith)) { return; } } if (webCookies.HasLogOn) { string message = ""; try { var identity = RemoteCache.Get <TIdentity>(context, "GetIdentity", "GanjiNETSSOIdentityKey_{0}"); if (identity != null) { var principal = (TPrincipal)Activator.CreateInstance(typeof(TPrincipal), identity); context.User = principal; return; } } catch (Exception ep) { message = ep.Message; } webCookies.ClearInternal(); context.Response.ContentEncoding = Encoding.UTF8; context.Response.HeaderEncoding = Encoding.UTF8; context.Response.Write( string.Format( @" <!DOCTYPE html><html><head> <title>请重新登录</title> <meta charset='utf-8' /> </head> <body> 用户认证失败,请重新<a href='" + AuthClient.GetLogOnUrl() + @"'>登录</a>!<br /> {0} </body></html> ", message)); context.Response.End(); } }
// ReSharper disable once TooManyDependencies public MobileSession( string oAuthToken, ulong?steamId, string steamLogin, string steamLoginSecure, string sessionId, string rememberLoginToken, Dictionary <ulong, string> steamMachineAuthenticationTokens) : base(steamId, steamLogin, steamLoginSecure, sessionId, rememberLoginToken, steamMachineAuthenticationTokens) { WebCookies.Add(new Cookie("mobileClientVersion", ClientVersion, "/", CommunityCookieDomain)); WebCookies.Add(new Cookie("mobileClient", ClientName, "/", CommunityCookieDomain)); OAuthToken = oAuthToken; SteamId = steamId; }
//find word anagrams public async Task <ViewResult> Anagram(String word) { string ip = LogActivities.GetIPAddress(); if (UsersLogService.IsPermittedToView(ip)) { //cookies - last searched words WebCookies.AddNewWordToHistory(Request, Response, word); //find anagrams -- find if there are cached words //List<string> anagrams = CachedWordService.FindAnagrams(word); List <string> anagrams = await Task.Run(() => (CachedWordService.FindAnagrams(word))); ViewBag.Anagrams = anagrams; //UserLog Task.Run(() => LogActivities.LogWordViewed(word)); } else { ViewBag.Permitted = false; } return(View("Index")); }