/// <summary>
        /// Sends a Login request to the API, and sets the current token, returns true if successful
        /// </summary>
        /// <returns></returns>
        public static bool Login(string email, string password)
        {
            string content = Request(RequestType.POST, LoginURL);

            Models.Auth.Login parsedResponse = JsonConvert.DeserializeObject <Models.Auth.Login>(content);

            if (!string.IsNullOrEmpty(parsedResponse.AccessToken))
            {
                AuthorsationToken = parsedResponse.AccessToken;
                TokenExpiry       = DateTime.Now.AddSeconds(parsedResponse.ExpiresInSeconds);

                return(true);
            }
            else
            {
                AuthorsationToken = "";
                TokenExpiry       = DateTime.Now.Subtract(TimeSpan.FromSeconds(1));

                return(false);
            }
        }
Beispiel #2
0
 public LoginPageViewModel()
 {
     Model = new Models.Auth.Login();
 }