Ejemplo n.º 1
0
        public void Handle(IUserSession userIssuingCommand, AddRoleToUser command)
        {
            var user = _readOnlyRepository.GetById <User>(command.UserId);
            var role = _readOnlyRepository.GetById <Role>(command.RolId);

            user.AddRol(role);

            _writeableRepository.Update(user);
            NotifyObservers(new UserRoleAdded(user.Id, role.Id));
        }
Ejemplo n.º 2
0
        public void Handle(IUserSession userIssuingCommand, EnableUser command)
        {
            var user = _readOnlyRepository.GetById <User>(command.id);

            user.EnableUser();

            _writeableRepository.Update(user);

            NotifyObservers(new UserEnabled(user.Id));
        }
Ejemplo n.º 3
0
        public void Handle(IUserSession userIssuingCommand, ResetPassword command)
        {
            var passwordResetToken = _readOnlyRepository.GetById <PasswordResetAuthorization>(command.ResetPasswordToken);
            var user = _readOnlyRepository.GetById <UserEmailLogin>(passwordResetToken.UserId);

            user.ChangePassword(command.EncryptedPassword);
            _writeableRepository.Update(user);
            _writeableRepository.Delete <PasswordResetAuthorization>(command.ResetPasswordToken);
            NotifyObservers(new PasswordReset(passwordResetToken.UserId));
        }