Exemplo n.º 1
0
        public void Trigger(CreatorCommand command)
        {
            var username = new AuthUsername(command.GetUsername());
            var password = new AuthPassword(command.GetPassword());

            Creator.Create(username, password, command.GetFirstName(), command.GetLastName());
        }
        public void Trigger(AuthenticateUserCommand command)
        {
            var username = new AuthUsername(command.GetUsername());
            var password = new AuthPassword(command.GetPassword());

            Authenticator.Authenticate(username, password);
        }
Exemplo n.º 3
0
        public void Authenticate(AuthUsername username, AuthPassword password)
        {
            var auth = Repository.Search(username);

            EnsureUserExist(auth, username);
            EnsureCredentialsAreValid(auth, password);
        }
Exemplo n.º 4
0
        public void Create(AuthUsername username, AuthPassword password
                           , string firtName, string lastName)
        {
            EnsureUsernameNotExists(username);

            int userRoleId = (int)Roles.Customer;

            userRoleId++;

            User user = new User
            {
                Purchases  = new List <Purchase>(),
                UserRoleId = userRoleId,
                Username   = username.GetValue(),
                Password   = password.GetValue(),
                FirstName  = firtName,
                LastName   = lastName
            };

            Repository.Save(user);
        }