Esempio n. 1
0
 /// <summary>
 /// Fill the current user with the necessary info
 /// </summary>
 /// <param name="u"></param>
 public void PopulateUser(MyUser u)
 {
     u.basic.SessionID = Session.id;
     u.basic.NickName = User.NickName;
     u.DisplayName = User.DisplayName;
     u.UserId = User.id;
     u.FileSizeLimit = FileSizeLimit;
     u.AccountType = AccountType.ToString();
     u.AccountStatus = AccountStatus.ToString();
     u.SmugVault = SmugVault;
     u.PasswordHash = PasswordHash;
     u.URL = User.URL;
 }
Esempio n. 2
0
 /// <summary>
 /// Authenticates a user based on the specified user id and password hash.
 /// </summary>
 /// <param name="UserId">The id for a specific user</param>
 /// <param name="PasswordHash">The password hash for the user</param>
 /// <param name="Extras">A comma separated string of additional attributes to return in the response</param>
 /// <returns>Login (AccountStatus, AccountType, FileSizeLimit, SessionID, SmugVault, User (id, DisplayName, NickName, URL))</returns>
 public MyUser Login(int UserId, string PasswordHash, string Extras)
 {
     CommunicationHelper ch = new CommunicationHelper();
     // APIKey [required], Callback, Extras, PasswordHash [required], Pretty, Sandboxed, Strict, UserID [required]
     string su;
     var resp = ch.ExecuteMethod<LoginResponse>("smugmug.login.withHash", null, out su, "UserID", UserId, "PasswordHash", PasswordHash, "Extras", Extras);
     if (resp.stat == "ok")
     {
         MyUser u = new MyUser();
         resp.Login.PopulateUser(u);
         u.basic._su = su;
         return u;
     }
     else
     {
         Console.WriteLine(resp.message);
         throw new SmugMugException(resp.code, resp.message, resp.method);
     }
 }
Esempio n. 3
0
 /// <summary>
 /// Authenticates a user based on the specified email address (or nickname) and password
 /// </summary>
 /// <param name="EmailAddress">The email address (or nickname) for the user.</param>
 /// <param name="Password">The password for the user.</param>
 /// <param name="Extras">A comma separated string of additional attributes to return in the response</param>
 /// <returns>Login (AccountStatus, Type, FileSizeLimit, PasswordHash, SessionID, SmugVault, User (id, DisplayName, NickName))</returns>
 public MyUser Login(string EmailAddress, string Password, string Extras)
 {
     CommunicationHelper ch = new CommunicationHelper();
     string su;
     // APIKey [required], EmailAddress [required], Password [required], Callback (JSON & PHP responses only), Extras, Pretty, Sandboxed, Strict
     var resp = ch.ExecuteMethod<LoginResponse>("smugmug.login.withPassword", null, out su,"EmailAddress", EmailAddress, "Password", Password, "Extras", Extras);
     if (resp.stat == "ok")
     {
         MyUser u = new MyUser();
         resp.Login.PopulateUser(u);
         u.basic._su = su;
         return u;
     }
     else
     {
         Console.WriteLine(resp.message);
         throw new SmugMugException(resp.code, resp.message, resp.method);
     }
 }
Esempio n. 4
0
 /// <summary>
 /// Establishes an anonymous session.
 /// </summary>
 /// <returns>Login (Session (id))</returns>
 public async Task<MyUser> LoginAsync()
 {
     // APIKey [required], Callback, Pretty, Strict
     CommunicationHelper ch = new CommunicationHelper();
     var resp = await ch.ExecuteMethod<LoginResponse>("smugmug.login.anonymously", null);
     if (resp.stat == "ok")
     {
         MyUser currentUser = new MyUser();
         if (currentUser.basic == null)
             currentUser.basic = new SmugMugBase();
         currentUser.basic.SessionID = resp.Login.Session.id;
         currentUser.basic.NickName = "";
         currentUser.DisplayName = "";
         return currentUser;
     }
     else
     {
         Console.WriteLine(resp.message);
         throw new SmugMugException(resp.code, resp.message, resp.method);
     }
 }