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

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

            return(messages);
        }
Ejemplo n.º 9
0
        public static ForumPageMetadata LoadBookmarks(this UserMetadata user)
        {
            UserBookmarksMetadata data = new UserBookmarksMetadata();

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