private void submit_login(object sender, RoutedEventArgs e) { var client = new AuthServiceClient(); string email = txt_email.Text; string password = txt_password.Password.ToString(); try { string token = client.LoginUser(email, password); if (!string.IsNullOrEmpty(token)) { Application.Current.Resources["Token"] = token; //create main window and dispose current one MainWindow main = new MainWindow(); main.Show(); this.Close(); } else { lbl_error.Content = "Invalid email or password"; } } catch (Exception) { } finally { client.Close(); } }
public UserContract Login(string userName, string password) { AuthServiceClient client = new AuthServiceClient(); UserContract retUser = client.Login(userName, password); client.Close(); if (retUser != null) { CreateCookie(userName, true); } return(retUser); }
public UserContract CreateUser(UserContract user) { AuthServiceClient client = new AuthServiceClient(); var createdUser = client.CreateUser(user); client.Close(); if (createdUser != null) { CreateCookie(createdUser.UserName, true); return(createdUser); } return(null); }
/// <summary> /// Users authentication service to get auth key /// </summary> /// <param name="sender"></param> /// <param name="args"></param> void GetAuthenticationKey(object sender, DoWorkEventArgs args) { var credentials = args.Argument as Credentials; try { var client = new AuthServiceClient(); args.Result = client.GetAuthKey(credentials.Username, credentials.Password); client.Close(); } catch (EndpointNotFoundException e) { args.Result = String.Empty; } }