예제 #1
0
 public static void MakeActive(this UserMetadata user)
 {
     if (!user.IsActive())
     {
         AwfulWebRequest.SetCredentials(user);
     }
 }
예제 #2
0
 public static void Logout(this UserMetadata user)
 {
     if (user.IsActive())
     {
         AwfulWebRequest.ClearCredentials();
     }
 }
예제 #3
0
 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));
     }
 }
예제 #4
0
        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);
        }
예제 #5
0
        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);
        }
예제 #6
0
 internal LoginEventArgs(UserMetadata metadata)
 {
     this.User = metadata;
 }
예제 #7
0
        public static IPrivateMessageRequest CreateNewPrivateMessage(this UserMetadata user)
        {
            var request = PrivateMessageService.Service.BeginNewMessageRequestAsync();

            return(request);
        }
예제 #8
0
        public static IEnumerable <PrivateMessageFolderMetadata> LoadPrivateMessageFolders(this UserMetadata user)
        {
            var messages = PrivateMessageService.Service.FetchFolders();

            return(messages);
        }
예제 #9
0
        public static ForumPageMetadata LoadBookmarks(this UserMetadata user)
        {
            UserBookmarksMetadata data = new UserBookmarksMetadata();

            return(data.Page(0));
        }
예제 #10
0
 public static bool RemoveFromUserBookmarks(this UserMetadata user, ThreadMetadata thread)
 {
     return(ThreadTasks.RemoveBookmark(thread));
 }
예제 #11
0
 public static bool AddToUserBookmarks(this UserMetadata user, ThreadMetadata thread)
 {
     return(ThreadTasks.AddBookmark(thread));
 }
예제 #12
0
 public static bool IsActive(this UserMetadata user)
 {
     return(AwfulWebRequest.ActiveUser.Equals(user) &&
            AwfulWebRequest.CanAuthenticate);
 }
예제 #13
0
 public void SetUserAndProceed(UserMetadata user)
 {
     AwfulWebRequest.SetCredentials(user);
     this.Ignore = true;
 }
예제 #14
0
 /// <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();
 }
예제 #15
0
 /// <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);
 }