public void When(AddSecurityPassword c) { var user = new UserId(_identityGenerator.GetId()); var salt = _generator.CreateSalt(); var token = _generator.CreateToken(); var hash = _generator.HashPassword(c.Password, salt); Apply(new SecurityPasswordAdded(c.Id, user, c.DisplayName, c.Login, hash, salt, token)); }
public void AddPassword(IDomainIdentityService ids, PasswordGenerator pwds, string display, string login, string password) { if (_state.ContainsLogin(login)) throw DomainError.Named("duplicate-login", "Login {0} is already taken", login); var user = new UserId(ids.GetId()); var salt = pwds.CreateSalt(); var token = pwds.CreateToken(); var hash = pwds.HashPassword(password, salt); Apply(new SecurityPasswordAdded(_state.Id, user, display, login, hash, salt, token)); }
public void AddPassword(IDomainIdentityService ids, IUserIndexService index, PasswordGenerator pwds, string display, string login, string password) { if (index.IsLoginRegistered(login)) { throw DomainError.Named("duplicate-login", "Login {0} is already taken", login); } var user = new UserId(ids.GetId()); var salt = pwds.CreateSalt(); var token = pwds.CreateToken(); var hash = pwds.HashPassword(password, salt); Apply(new SecurityPasswordAdded(_state.Id, user, display, login, hash, salt, token)); }
public void When(IDomainIdentityService ids, PasswordGenerator pwds, CreateSecurityFromRegistration c) { Apply(new SecurityAggregateCreated(c.Id)); var user = new UserId(ids.GetId()); var salt = pwds.CreateSalt(); var token = pwds.CreateToken(); var hash = pwds.HashPassword(c.Pwd, salt); Apply(new SecurityPasswordAdded(c.Id, user, c.DisplayName, c.Login, hash, salt, token)); if (!string.IsNullOrEmpty(c.OptionalIdentity)) { AddIdentity(ids, pwds, c.DisplayName, c.OptionalIdentity); } Apply(new SecurityRegistrationProcessCompleted(c.Id, c.DisplayName, user, token, c.RegistrationId)); }