Exemple #1
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 async Task<MyUser> LoginAsync(int UserId, string PasswordHash, string Extras)
        {
            CommunicationHelper ch = new CommunicationHelper();
            // APIKey [required], Callback, Extras, PasswordHash [required], Pretty, Sandboxed, Strict, UserID [required]

            var tuple = await ch.ExecuteMethodReturnCookie<LoginResponse>("smugmug.login.withHash", null, "UserID", UserId, "PasswordHash", PasswordHash, "Extras", Extras);
            var resp = tuple.Item1;
            string su = tuple.Item2;
            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);
            }
        }