public CommandResult Register(UserRegisterCommand command) { var exist = _repository.Exists(command.Username); if (exist) { AddNotification("Já existe um Usuario cadastrado com esse Nome. "); } var user = new UserAuth(command.Username, command.Password); AddNotifications(user); if (Invalid) { return(new CommandResult(false, GroupNotifications.Group(Notifications), command)); } // Add Hash e Salt var salt = Salt.Create(); var hash = Hash.Create(user.Password, salt); if (!Hash.Validate(user.Password, salt, hash)) { AddNotification("Erro na geração do Hash. "); } user.AddHash(hash, Convert.ToBase64String(salt)); _repository.Register(user); var log = new AccessLog( "Register", DateTime.Now, "auto registro", "UserAuth", $"Nome usuario registrado: {command.Username}"); _log.Register(log); user.HidePassword(); return(new CommandResult(true, "Cadastro realizado. ", user)); }