public static void MakeActive(this UserMetadata user) { if (!user.IsActive()) { AwfulWebRequest.SetCredentials(user); } }
public static void Logout(this UserMetadata user) { if (user.IsActive()) { AwfulWebRequest.ClearCredentials(); } }
private static void OnLoginSuccessful(AwfulLoginClient sender, string username, List <Cookie> cookie) { if (LoginSuccessful != null) { var user = new UserMetadata() { Username = username, Cookies = cookie }; LoginSuccessful(sender, new LoginEventArgs(user)); } }
public static IEnumerable <ForumMetadata> LoadForums(this UserMetadata user) { if (user.Username.Equals(AwfulLoginClient.TEST_USER, StringComparison.CurrentCultureIgnoreCase)) { ForumParser.UseWhitelist = true; } else { ForumParser.UseWhitelist = false; } var forums = ForumTasks.FetchAllForums(); return(forums); }
public static bool Login(this UserMetadata user, string password) { var login = new AwfulLoginClient(); var cookies = login.Authenticate(user.Username, password); bool success = false; if (cookies != null) { success = true; user.Cookies = cookies; AwfulWebRequest.SetCredentials(user); } return(success); }
internal LoginEventArgs(UserMetadata metadata) { this.User = metadata; }
public static IPrivateMessageRequest CreateNewPrivateMessage(this UserMetadata user) { var request = PrivateMessageService.Service.BeginNewMessageRequestAsync(); return(request); }
public static IEnumerable <PrivateMessageFolderMetadata> LoadPrivateMessageFolders(this UserMetadata user) { var messages = PrivateMessageService.Service.FetchFolders(); return(messages); }
public static ForumPageMetadata LoadBookmarks(this UserMetadata user) { UserBookmarksMetadata data = new UserBookmarksMetadata(); return(data.Page(0)); }
public static bool RemoveFromUserBookmarks(this UserMetadata user, ThreadMetadata thread) { return(ThreadTasks.RemoveBookmark(thread)); }
public static bool AddToUserBookmarks(this UserMetadata user, ThreadMetadata thread) { return(ThreadTasks.AddBookmark(thread)); }
public static bool IsActive(this UserMetadata user) { return(AwfulWebRequest.ActiveUser.Equals(user) && AwfulWebRequest.CanAuthenticate); }
public void SetUserAndProceed(UserMetadata user) { AwfulWebRequest.SetCredentials(user); this.Ignore = true; }
/// <summary> /// Removes the cookies for all global web requests. Any future requests which require /// authentication will fail until credentials are set again. /// </summary> internal static void ClearCredentials() { _user = null; _cookieJar.Clear(); }
/// <summary> /// Sets the global cookie container for all future web requests to that of the specified user. /// If the user has invalid cookies, future requests may fail. This method is typically called /// after authentication cookies are obtained. /// </summary> /// <param name="user">The specified user.</param> internal static void SetCredentials(UserMetadata user) { _user = user; SetCookieJar(user.Cookies); }