static StoredSettings() { TranslationManager.Instance.LanguageChanged += OnLanguageChanged; IVtsWebService client = Infrastructure.Container.GetInstance <IVtsWebService>(); try { if (client.CheckConnection() == "ok") { string login = AgentIsolatedStorageHelper.Login; string passwordHash = AgentIsolatedStorageHelper.PasswordHash; if (String.IsNullOrEmpty(login) || String.IsNullOrEmpty(passwordHash)) { return; } UserDto userDto = client.AuthenticateUser(login, passwordHash); if (userDto != null) { storedUser = UserAssembler.FromDtoToDomainObject(userDto); } else { Log.Warn("Could not log on with stored credentials!"); } TranslationManager.Instance.CurrentLanguageEnum = AgentIsolatedStorageHelper.Language; } } catch (Exception p) { Log.Error(p.Message); } }
/// <summary> /// Action uset lo log in a user after he has entered his credentials. /// </summary> public ActionResult Signin(string emailOrLogin, string password, string language) { string passwordHash = Sha256Hash.Calculate(password); UserDto user = service.AuthenticateUser(emailOrLogin, passwordHash); if (user == null) { TempData["LogonFailed"] = true; return(View("Logon")); } Session["User"] = UserAssembler.FromDtoToDomainObject(user); Session["Lang"] = LangConverter.Convert(language); return(RedirectToAction("Index", "Vehicles")); }
private void GoForward() { if (IsRegister) { User user = new User(); user.Login = Username; user.PasswordHash = Sha256Hash.Calculate(PasswordText); user.Role = UserRole.Partner; user.RegisteredDate = DateTime.Now; user.Email = Email; user.Name = "???"; user.Phone = "???"; user.Profile = null; user.Surname = "???"; UserDto userDto = UserAssembler.FromDomainObjectToDto(user); IVtsWebService service = Infrastructure.Container.GetInstance <IVtsWebService>(); try { service.RegisterUser(userDto); UserDto userDtoNew = service.AuthenticateUser(Username, Sha256Hash.Calculate(PasswordText)); User userNew = UserAssembler.FromDtoToDomainObject(userDtoNew); LoggedUserContext.LoggedUser = userNew; StoredSettings.Current = userNew; } catch (Exception e) { Log.Error(e, e.Message); ErrorWindow wnd = new ErrorWindow(e.Message); wnd.Owner = MainWindowKeeper.MainWindowInstance as Window; wnd.ShowDialog(); } } else if (IsLogon) { VtsWebServiceClient service = new VtsWebServiceClient(); try { UserDto userDto = service.AuthenticateUser(Username, Sha256Hash.Calculate(PasswordText)); if (userDto != null) { User user = UserAssembler.FromDtoToDomainObject(userDto); LoggedUserContext.LoggedUser = user; StoredSettings.Current = user; } else { ShowIncorrectCredentialsText(); } } catch (Exception e) { Log.Error(e, e.Message); ErrorWindow wnd = new ErrorWindow(e.Message); wnd.Owner = MainWindowKeeper.MainWindowInstance as Window; wnd.ShowDialog(); } } }