public ActionResult Login(FormCollection collection) { using (ServiceHelper serviceHelper = new ServiceHelper()) { try { LoginViewModel lvm = new LoginViewModel { Username = Convert.ToString(collection["Username"]), Password = Convert.ToString(collection["Password"]) }; AuthServiceClient authClient = serviceHelper.GetAuthServiceClient(); if (authClient.Login(lvm.Username, lvm.Password)) { AuthHelper.Login(lvm); lvm.Id = serviceHelper.GetCustomerServiceClient().FindCustomerByUsername(lvm.Username).Id; } else { throw new InvalidLoginException(); } return(RedirectToAction("Index", "Home")); } catch { return(View()); } } }
private async void LogInButton_OnClick(object sender, RoutedEventArgs e) { if (string.IsNullOrWhiteSpace(LoginTextBox.Text) || string.IsNullOrWhiteSpace(PasswordTextBox.Password)) { await this.ShowMessageAsync("Warning", "Please fill login and password fields"); return; } var user = _authService.Login(LoginTextBox.Text, PasswordTextBox.Password); if (user == null) { await this.ShowMessageAsync("Warning", "You entered incorrect login or password"); return; } switch (user.Role) { case UserRoles.Doctor: var doctor = _doctorService.GetDoctor(user.Id); new DoctorWindow(doctor).Show(); Close(); break; case UserRoles.Patient: var patient = _patientService.GetPatient(user.Id); new PatientWindow(patient).Show(); Close(); break; } }
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 JsonResult Login(Qz.GPS.DirectService.Parameter.User.Login user) { SsoService.AuthServiceClient auth = new AuthServiceClient(); var token = auth.Login(user.Account, user.Password); return Json( new Qz.Core.Entity.Response() { Message = token } ); }
public bool Login(string username, string password) { using (AuthServiceClient authClient = _serviceManager.GetAuthServiceClient()) { if (authClient.Login(username, password)) { var cookie = _cookieSetup.CreateEncryptedAuthenticationCookie("roh", "han"); //Cookie is encrypted using AES(using machineKey and transmitted to the client. Key is on server. Cannot realistically be decrypted. Password not transmitted in this case System.Web.HttpContext.Current.Response.Cookies.Add(cookie); _sessionManager.SetLoggedInSession(new CustomPrincipalSerializeModel { FirstName = "John", LastName = "Doe" }); return(true); } else { return(false); } } }
public ActionResult Login(string userName, string uPassword) { bool check = UserClient.Login(userName, uPassword); int id = 0; ServicePointManager.ServerCertificateValidationCallback = (obj, certificate, chain, errors) => true; AuthServiceClient authClient = new AuthServiceClient(); var isLoggedIn = authClient.Login(userName, uPassword); if (isLoggedIn) { id = UserClient.GetUserByUserName(userName).ID; SecurityServiceClient client = new SecurityServiceClient("WSHttpBinding_ISecurityService"); client.ClientCredentials.UserName.UserName = userName; client.ClientCredentials.UserName.Password = uPassword; var data = client.GetData(1337); } return(RedirectToAction("Index", new { id = id })); }
public async Task <User> AuthenticateAsync(string username, string password) { try { if (AreCredentialsAvaible() && HasValidCredentialsAvaible()) { return(GetStoredUser()); } var encryptedPassword = crypto.Encrypt(password); var userModel = await authServiceClient.Login(new UserModel { Email = username, Password = encryptedPassword }); var user = new User { Id = userModel.Id, Email = userModel.Email, Password = password, ChangeStamp = DateTime.Now, LastApiCall = DateTime.Now, Token = userModel.Token }; await SaveOrUpdateUser(user); return(user); } catch (Exception ex) { throw ex; } finally { isAuthenticated = true; OnAuthenticationChanged?.Invoke(this, EventArgs.Empty); } }
private void butLoggin_Click(object sender, RoutedEventArgs e) { String login = TBoxLogin.Text; String password = TBoxPass.Password; AuthServiceClient client = new AuthServiceClient(); String sessionId = client.Login(login, password); if (sessionId != null) { App.Current.Properties[App.sessionPropertyName] = sessionId; App.Current.Properties[App.loginPropertyName] = login; MainWindow mainWindow = new MainWindow(); mainWindow.Show(); this.Close(); } else { LabelErrorLogin.Visibility = Visibility.Visible; } }
static void Main(string[] args) { ServicePointManager.ServerCertificateValidationCallback = (obj, certificate, chain, errors) => true; AuthServiceClient authClient = new AuthServiceClient(); var isLoggedIn = authClient.Login("*****@*****.**", "!# test password #!"); if (isLoggedIn) { Console.WriteLine("AuthService authentication succeeded."); SocialAdServiceClient cl = new SocialAdServiceClient(); cl.ClientCredentials.UserName.UserName = "******"; cl.ClientCredentials.UserName.Password = "******"; var data = cl.getData(); var post = cl.GenerateTestPost("Hvis dette virker, er det rigtig spændende."); Console.WriteLine(data); Console.WriteLine(post.DatePosted); Console.WriteLine(post.Content); Console.ReadLine(); } else { Console.WriteLine("Could not log in with AuthService."); } }
private static void Login(string username, string password) { IsUserLoggedIn = authClient.Login(username, password); }