public Account( string firstname, string lastname, MailAddress email, Password password, AccountRole role, ConfirmationStatus confirmationStatus, DateTime registrationTime, Profile profile, int redmineUserId, int gitlabUserId) { Require.NotEmpty(firstname, nameof(firstname)); Require.NotEmpty(lastname, nameof(lastname)); Require.NotNull(email, nameof(email)); Require.NotNull(password, nameof(password)); Require.ZeroOrGreater(redmineUserId, nameof(redmineUserId)); Require.ZeroOrGreater(gitlabUserId, nameof(gitlabUserId)); Require.NotNull(email, nameof(email)); Require.NotNull(password, nameof(password)); Firstname = firstname; Lastname = lastname; Email = email; Password = password; Role = role; ConfirmationStatus = confirmationStatus; RegistrationTime = registrationTime; Profile = profile; RedmineUserId = redmineUserId; GitlabUserId = gitlabUserId; }
public AuthorizationTokenInfo Authorize(string email, Password password) { Require.NotEmpty(email, nameof(email)); Require.NotNull(password, nameof(password)); var userAccount = _userRepository .GetAllAccounts( account => account.Email.Address == email && account.ConfirmationStatus == ConfirmationStatus.FullyConfirmed) .SingleOrDefault(); if (userAccount == null) { throw new AccountNotFoundException("There is no account with such email"); } if (userAccount.Password.Value != password.Value) { throw new UnauthorizedAccessException("Wrong password"); } var existantToken = TakeTokenByUserId(userAccount.UserId); if (existantToken != null) { return existantToken; } var token = GenerateNewToken(userAccount); _tokensWithGenerationTime.AddOrUpdate(token.Token, token, (oldToken, info) => token); return token; }
public void InvalidPasswordThrowsArgumentException() { //arrange var tooShortPass = "******"; var tooLongPass = "******"; //act var errPass1 = new Password(tooShortPass); var errPass2 = new Password(tooLongPass); //assert }
public void CorrectPasswordCreateObjectOfPasswordClassWithCorrectHash() { //arrange var correctPass = "******"; //act var pass = new Password(correctPass); //assert Assert.IsNotNull(pass); Assert.IsTrue(pass.Value == @"22d7fe8c185003c98f97e5d6ced420c7"); }
protected bool Equals(Password other) { return string.Equals(Value, other.Value); }
private async void McuSendPassword() { await Task.Delay(1000); var z = new Password(LibraryData.Settings["defaultPw"] ?? "579ACE", false); QueueData(z); await z.WaitAsync(); if (z.PasswordCorrect) { _mcucomm.Fire(Cevts.PasswordOk); } else { _mcucomm.Fire(Cevts.Error, "Wrong password"); } }