private async void LoginButton_Click(object sender, RoutedEventArgs e) { String url = "http://192.168.231.51/YourEarth/login.php"; var values = new List <KeyValuePair <string, string> > { new KeyValuePair <string, string> ("pseudo", login.Text), new KeyValuePair <string, string> ("password", pass.Password), }; var httpClient = new HttpClient(new HttpClientHandler()); HttpResponseMessage response = await httpClient.PostAsync(url, new FormUrlEncodedContent(values)); response.EnsureSuccessStatusCode(); var responseString = await response.Content.ReadAsStringAsync(); if (responseString.Equals("")) { MessageBox.Show("Mot de Passe incorrect"); } else { models.User user = JsonConvert.DeserializeObject <models.User>(responseString); models.Data.user = user; NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative)); } }
public void CheckFormEmailAlredyUsedExceptionTest() { models.User user = new models.User() { Nickname = "uniqueNicknames", Email = email }; users.Add(user); Assert.ThrowsException <EmailAlredyUsedException>(() => UserFormUtils.CheckForm(name, surname, email, nickname, password, password2, users)); }
public static void UserPost( string username = null, // str of the username give my the player string email = null, // str of the user's email address string full_name = null, // str of the full name string password = null) // str of the password which will be hashed { /* * This will update a PnP user */ if (benChristenson.userPost == null) { benChristenson.userPost = m_instance.gameObject.AddComponent <behaviors.UserPost>(); benChristenson.userPost.DestroyOnComplete = benChristensonApiInitialize.is_behavior_destroyed_on_complete(); } if (m_logLevel > 3) { Debug.Log(Prefix() + "UserPost started"); } benChristenson.userPost.Spawn(username, email, full_name, password, Callback: new Action <operations.UserPost, HttpResponse> ((operation, response) => { try { if (response.HasError) { if (m_logLevel > 1) { Debug.LogError(Prefix() + "UserPost failed " + response.Error); } } else { models.User responseData = operation.responseData; // User dict of the user updated if (m_logLevel > 2) { Debug.Log(Prefix() + "UserPost completed Successfully with " + responseData.ToString()); } } } catch (Exception ex) { if (m_logLevel > 0) { Debug.LogError(Prefix() + "UserPost failed in response with: " + ex.ToString()); } } })); }
public static void UserLoginPost( string username, // str of the username string password, // str of the password string email = null) // str of the email as an alternative to username { /* * This will process logging the user in */ if (benChristenson.userLoginPost == null) { benChristenson.userLoginPost = m_instance.gameObject.AddComponent <behaviors.UserLoginPost>(); benChristenson.userLoginPost.DestroyOnComplete = benChristensonApiInitialize.is_behavior_destroyed_on_complete(); } if (m_logLevel > 3) { Debug.Log(Prefix() + "UserLoginPost started"); } benChristenson.userLoginPost.Spawn(username, password, email, Callback: new Action <operations.UserLoginPost, HttpResponse> ((operation, response) => { try { if (response.HasError) { if (m_logLevel > 1) { Debug.LogError(Prefix() + "UserLoginPost failed " + response.Error); } } else { models.User responseData = operation.responseData; // User dict if (m_logLevel > 2) { Debug.Log(Prefix() + "UserLoginPost completed Successfully with " + responseData.ToString()); } } } catch (Exception ex) { if (m_logLevel > 0) { Debug.LogError(Prefix() + "UserLoginPost failed in response with: " + ex.ToString()); } } })); }
public static void UserGet() { if (benChristenson.userGet == null) { benChristenson.userGet = m_instance.gameObject.AddComponent <behaviors.UserGet>(); benChristenson.userGet.DestroyOnComplete = benChristensonApiInitialize.is_behavior_destroyed_on_complete(); } if (m_logLevel > 3) { Debug.Log(Prefix() + "UserGet started"); } benChristenson.userGet.Spawn( Callback: new Action <operations.UserGet, HttpResponse> ((operation, response) => { try { if (response.HasError) { if (m_logLevel > 1) { Debug.LogError(Prefix() + "UserGet failed " + response.Error); } } else { models.User responseData = operation.responseData; // User dict of the current user if (m_logLevel > 2) { Debug.Log(Prefix() + "UserGet completed Successfully with " + responseData.ToString()); } } } catch (Exception ex) { if (m_logLevel > 0) { Debug.LogError(Prefix() + "UserGet failed in response with: " + ex.ToString()); } } })); }
public async Task <IActionResult> UpdatedUser(int id, UserForUpdateDto userForUpdateDto) { if (id != int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value)) { return(Unauthorized()); } models.User user1 = await _repo.GetUser(id); var userFromRepo = user1; models.User user = _mapper.Map(userForUpdateDto, userFromRepo); if (await _repo.SaveAll()) { return(NoContent()); } throw new Exception($"Updating user {id} failed on save"); }
public async Task <bool> UpdateUser(string user) { try { User newUser = new models.User(); try { newUser = JsonConvert.DeserializeObject <User>(user); } catch { Debug.WriteLine("ERRR"); } int a = 6; a = a + 5; db.user.Update( newUser ); await db.SaveChangesAsync(); return(true); } catch { return(false); } }
public AdminPanel(models.User user) { InitializeComponent(); }
private void OnFail(operations.UserPost operation, HttpResponse response) { responseData = null; Status = ApiBehaviorStatus.FAILURE; }
public models.User responseData; // User dict of the user updated private void OnSuccess(operations.UserPost operation, HttpResponse response) { responseData = operation.responseData; Status = ApiBehaviorStatus.SUCCESS; }
public User(models.User user) { this.id = user.id.ToString(); this.name = user.name; }