onzulin

login de usuario

Nov 5th, 2014
548
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.71 KB | None | 0 0
  1. public async static Task<bool> VerifyLogin(string email, string password)
  2.         {
  3.             HttpClient httpClient = new HttpClient();
  4.             JsonObject jsonObject = new JsonObject();
  5.             //vamos a ver la forma de trabajar con texto con json segun el ejemplo de Microsoft y adaprlo a mi codigo segun lo que tenga que enviar
  6.             jsonObject["username"] = JsonValue.CreateStringValue(email);
  7.             jsonObject["password"] = JsonValue.CreateStringValue(password);
  8.             string jsonString = jsonObject.Stringify();
  9.             HttpStringContent httpStringContent = new HttpStringContent(jsonString, Windows.Storage.Streams.UnicodeEncoding.Utf8, "application/json");
  10.             Uri uri = new Uri("http://192.168.1.2/laravelplan/public/api/rest/auth/login");
  11.             HttpResponseMessage response = new HttpResponseMessage();
  12.             try
  13.             {
  14.                 response = await httpClient.PostAsync(uri, httpStringContent);
  15.             }
  16.             catch (Exception ex)
  17.             {
  18.                 MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK);
  19.             }
  20.             if (!response.IsSuccessStatusCode)
  21.             {
  22.                 //string message = response
  23.                 MessageBox.Show(response.Content.ToString(), "Error", MessageBoxButton.OK);
  24.                 return false;
  25.             }
  26.            
  27.             /*
  28.             if (dbUser != null)
  29.             {
  30.                 usuarios localUser = GetSecureUserModel(username, password, "",
  31.                     GetSaltFromString(dbUser.salt));
  32.                 if (dbUser.hash == localUser.hash)
  33.                     return dbUser;
  34.             }
  35.             */
  36.             return true;
  37.         }
Advertisement
Add Comment
Please, Sign In to add comment