private void gmcInput_Validating(object sender, CancelEventArgs e) { string input = gmcInput.Text; if (string.IsNullOrEmpty(input)) { errorProvider1.SetError(gmcInput, "Please enter GMC Number!"); } else if (input.Length != 7) { errorProvider1.SetError(gmcInput, "GMC should be 7 digits long!"); } else if (!CredentialsValidator.IsValid(input)) { errorProvider1.SetError(gmcInput, "GMC contains forbidden symbols!"); } else if (Main.HospitalStructure.Employees.Any(any => any.GMC != null && any.GMC == input)) { if (this.state == "Edit" && _currentEmployee.GMC == input) { errorProvider1.SetError(gmcInput, null); } else { errorProvider1.SetError(gmcInput, "This GMC is already used!"); } } else { errorProvider1.SetError(gmcInput, null); } }
private void passwordInput_Validating(object sender, CancelEventArgs e) { string input = passwordInput.Text; if (this.state == "Edit" && input == "") { errorProvider1.SetError(passwordInput, null); } else if (string.IsNullOrEmpty(input)) { errorProvider1.SetError(passwordInput, "Please enter your password!"); } else if (input.Length < 6) { errorProvider1.SetError(passwordInput, "Password should be at least 6 digits long!"); } else if (!CredentialsValidator.IsValid(input)) { errorProvider1.SetError(passwordInput, "Password contains forbidden symbols!"); } else { errorProvider1.SetError(passwordInput, null); } }
private void loginInput_Validating(object sender, CancelEventArgs e) { string input = loginInput.Text; if (string.IsNullOrEmpty(input)) { errorProvider1.SetError(loginInput, "Please enter your login!"); } else if (input.Length < 6) { errorProvider1.SetError(loginInput, "Login should be at least 6 digits long!"); } else if (!CredentialsValidator.IsValid(input)) { errorProvider1.SetError(loginInput, "Login contains forbidden symbols!"); } else if (Main.HospitalStructure.Employees.Any(any => any.Login == input)) { errorProvider1.SetError(loginInput, "This login is already used!"); } else { errorProvider1.SetError(loginInput, null); } }
public string GenerateToken() { ICredentialsValidator validator = new CredentialsValidator(); if (validator.IsValid()) { return(new TokenBuilder().Build()); } throw new InvalidCredentialException("Credencial inválida."); }
public string Authenticate(Credentials creds) { CredentialsValidator validator = new CredentialsValidator(); if (validator.IsValid(creds)) { return(new TokenBuilder().Build(creds)); } throw new InvalidOperationException("Invalid credentials"); }
public static void RegisterUser(string username, string password) { var validator = new CredentialsValidator(); var validationException = validator.Validate(new ValidatedObject(username, password)); if (validationException != null) { throw new Exception($"Your {validationException.NotValidField} is not valid, " + $"Exception: {validationException.Message}"); } ApplicationRepository.AddUser(username, password); }
public UserService(IUserRepository repository, IMapper mapper, ITokenService tokenService, UserValidator userValidator, UpdateUserValidator updateUserValidator, CredentialsValidator credentialsValidator, IFileRepository fileRepository, IProviderCacheRepository providerCacheRepository) { _repository = repository; _mapper = mapper; _tokenService = tokenService; _userValidator = userValidator; _updateUserValidator = updateUserValidator; _credentialsValidator = credentialsValidator; _fileRepository = fileRepository; _providerCacheRepository = providerCacheRepository; }
/// <summary> /// Verifies that the credentials are valid according to the given spec, /// if so navigation to the content page is allowed, otherwise an error is displayed to the user. /// </summary> private void OnLogin() { var results = CredentialsValidator.Validate(new LoginCredentials(Username, Password)); if (results.Any()) { var message = results.Select(v => v.Message).Aggregate((a, b) => a + "\r\n\r\n" + b); MessageBox.Show(message, AppResources.DialogErrorCaption, MessageBoxButton.OK); } else { NavigationService.NavigateTo(PageUri.ContentPageUri); } }
public ZooPark GetZoo(string username, string password) { var validator = new CredentialsValidator(); var validationException = validator.Validate(new ValidatedObject(username, password)); if (validationException != null) { throw new Exception($"Your {validationException.NotValidField} is not valid, " + $"Exception: {validationException.Message}"); } if (ApplicationRepository.CheckUserAllowedToAccess(username, password)) { return(zooLoader.GetZoo(username, password)); } throw new Exception("There is no user with such login-password match"); }
private void loginInput_Validating(object sender, CancelEventArgs e) { if (string.IsNullOrEmpty(loginInput.Text)) { errorProvider1.SetError(loginInput, "Please enter your login!"); } else if (loginInput.Text.Length < 6) { errorProvider1.SetError(loginInput, "Login should be at least 6 digits long!"); } else if (!CredentialsValidator.IsValid(loginInput.Text)) { errorProvider1.SetError(loginInput, "Login contains forbidden symbols!"); } else { errorProvider1.SetError(loginInput, null); } }
private void surnameInput_Validating(object sender, CancelEventArgs e) { string input = surnameInput.Text; if (string.IsNullOrEmpty(input)) { errorProvider1.SetError(surnameInput, "Please enter surname!"); } else if (input.Length < 2) { errorProvider1.SetError(surnameInput, "Surname should be at least 2 digits long!"); } else if (!CredentialsValidator.IsValid(input)) { errorProvider1.SetError(surnameInput, "Surname contains forbidden symbols!"); } else { errorProvider1.SetError(surnameInput, null); } }
/// <summary> /// Loads the authenticator plugins and tries to authenticate to each of them. /// </summary> /// <param name="creds">The credentials, user name and password, to authenticate with.</param> /// <returns>A token if authenticated.</returns> /// <exception>AuthenticationException</exception> public IToken Authenticate(Credentials creds) { if (creds == null && WebOperationContext.Current != null) { var basicAuthHeader = WebOperationContext.Current.IncomingRequest.Headers["Authorization"]; if (!string.IsNullOrWhiteSpace(basicAuthHeader)) { creds = new BasicAuth(basicAuthHeader).Creds; } } IToken token; if (CredentialsValidator.IsValid(creds, out token)) { return(token); } else { throw new AuthenticationException("Invalid credentials."); } }
void OnSubmitDetails() { bool validInput = true; submitDetailsBtn.interactable = false; if (!CredentialsValidator.validateName(nameIF.text)) { validInput = false; submitDetailsBtn.interactable = false; nameIF.image.color = Color.red; nameIF.transform.DOShakePosition(0.5f, new Vector3(50, 0, 0), 5, 90, true, true).OnComplete(() => { nameIF.image.color = Color.white; submitDetailsBtn.interactable = true; }); } //if (!CredentialsValidator.validateEmail(emailIF.text)) //{ // validInput = false; // submitDetailsBtn.interactable = false; // emailIF.image.color = Color.red; // emailIF.transform.DOShakePosition(0.5f, new Vector3(50, 0, 0), 5, 90, true, true).OnComplete(() => // { // emailIF.image.color = Color.white; // submitDetailsBtn.interactable = true; // }); //} //if (!CredentialsValidator.validateMobile(contactIF.text)) //{ // validInput = false; // submitDetailsBtn.interactable = false; // contactIF.image.color = Color.red; // contactIF.transform.DOShakePosition(0.5f, new Vector3(50, 0, 0), 5, 90, true, true).OnComplete(() => // { // contactIF.image.color = Color.white; // submitDetailsBtn.interactable = true; // }); //} if (validInput) { TrinaxManager.trinaxAudioManager.PlayUISFX(TrinaxAudioManager.AUDIOS.VALID, TrinaxAudioManager.AUDIOPLAYER.UI_SFX); //GameManager.Instance.userData.name = nameIF.text; //GameManager.Instance.userData.mobileno = ""; //GameManager.Instance.userData.email = ""; //GameManager.Instance.userData.score = ScoreManager.Instance.Score.ToString(); //await APICalls.RunAddGameResult(); PlayerInfo pInfo = new PlayerInfo() { name = nameIF.text, score = ScoreManager.Instance.Score, }; AppManager.leaderboardManager.Save(pInfo); AppManager.uiManager.ToScreensaver(); AppManager.gameManager.screensaver.state = SCREENSAVER_STATE.LEADER; //APICalls.RunEndInteraction().WrapErrors(); } else { TrinaxManager.trinaxAudioManager.PlayUISFX(TrinaxAudioManager.AUDIOS.INVALID, TrinaxAudioManager.AUDIOPLAYER.UI_SFX); } }
public void Startup() { _validator = new CredentialsValidator(MockIRestClient.Object, CredentialsForTest); }
async void OnSubmit() { bool validInput = true; if (!CredentialsValidator.validateName(nameIF.text)) { validInput = false; submitButton.interactable = false; nameIF.image.DOColor(Color.red, 0.25f); nameIF.transform.DOShakePosition(0.25f, new Vector3(50, 0), 5, 90, false, true).OnComplete(() => { nameIF.image.DOColor(Color.white, 0.25f); submitButton.interactable = true; }); } if (!CredentialsValidator.validateMobile(contactIF.text)) { validInput = false; submitButton.interactable = false; contactIF.image.DOColor(Color.red, 0.25f); contactIF.transform.DOShakePosition(0.25f, new Vector3(50, 0), 5, 90, false, true).OnComplete(() => { contactIF.image.DOColor(Color.white, 0.25f); submitButton.interactable = true; }); } if (!PDAToggle.isOn) { validInput = false; submitButton.interactable = false; PDAToggle.image.DOColor(Color.red, 0.25f); PDAToggle.transform.DOShakePosition(0.25f, new Vector3(50, 0), 5, 90, false, true).OnComplete(() => { PDAToggle.image.DOColor(Color.white, 0.25f); submitButton.interactable = true; }); } if (validInput) { TrinaxAudioManager.Instance.PlayUISFX(TrinaxAudioManager.AUDIOS.BUTTON_CLICK, TrinaxAudioManager.AUDIOPLAYER.UI_SFX); PlayerInfo pInfo = new PlayerInfo { name = nameIF.text, score = AppManager.Instance.scoreManager.Score, mobile = contactIF.text, }; AppManager.Instance.localLeaderboard.Save(pInfo); TrinaxGlobal.Instance.userData.name = nameIF.text; TrinaxGlobal.Instance.userData.score = AppManager.Instance.scoreManager.Score.ToString(); TrinaxGlobal.Instance.userData.mobile = contactIF.text; await APICalls.RunAddGameResult(); AppManager.Instance.uiManager.backgroundCanvas.Activate(0, true); AppManager.Instance.uiManager.ToScreensaver(SCREENSAVER_STATE.LEADERBOARD); } else { TrinaxAudioManager.Instance.PlayUISFX(TrinaxAudioManager.AUDIOS.INVALID, TrinaxAudioManager.AUDIOPLAYER.UI_SFX); } }