Allow loading an existing session into an IAuth (create a UserSession, pass it in)

This commit is contained in:
Rikki Tooley 2013-06-23 23:58:42 +01:00
parent 6ee13480cc
commit 6b98c368a9
2 changed files with 18 additions and 0 deletions

View File

@ -30,6 +30,17 @@ public Auth(string apikey, string secret)
_apiSecret = secret; _apiSecret = secret;
} }
/// <summary>
/// Load an existing user session
/// </summary>
/// <param name="session">Session to load</param>
/// <returns>Whether session object is valid</returns>
public bool LoadSession(UserSession session)
{
User = session;
return true;
}
public async Task<LastResponse> GetSessionTokenAsync(string username, string password) public async Task<LastResponse> GetSessionTokenAsync(string username, string password)
{ {
const string apiMethod = "auth.getMobileSession"; const string apiMethod = "auth.getMobileSession";

View File

@ -11,6 +11,13 @@ public interface IAuth
string ApiKey { get; } string ApiKey { get; }
UserSession User { get; } UserSession User { get; }
/// <summary>
/// Load an existing user session object.
/// </summary>
/// <param name="session"></param>
/// <returns>Whether session object is valid</returns>
bool LoadSession(UserSession session);
/// <summary> /// <summary>
/// Gets the session token which is used as authentication for any service calls. /// Gets the session token which is used as authentication for any service calls.
/// Username and password aren't stored. /// Username and password aren't stored.