Skip to content

feat(auth): add password change endpoint#20

Merged
tnramalho merged 34 commits into
btwld:mainfrom
tnramalho:feature/role-type
Jan 29, 2026
Merged

feat(auth): add password change endpoint#20
tnramalho merged 34 commits into
btwld:mainfrom
tnramalho:feature/role-type

Conversation

@tnramalho
Copy link
Copy Markdown
Collaborator

Summary

  • Added change password endpoint (MePasswordController) with full CRUD support including DTO validation and unit tests
  • Updated user metadata DTOs for Swagger documentation (create, update, and base user DTOs across rockets-server-auth and rockets-server)
  • Added RocketsOptionsExtrasInterface with configurable roleType support in module definitions
  • Version bumps for rockets-server and rockets-server-auth packages
  • Updated Swagger spec generation with expanded endpoint coverage
  • Added .cursor/rules/testing.mdc skill file

Test plan

  • Verify MePasswordController change password flow works end-to-end
  • Confirm Swagger JSON reflects updated user metadata fields
  • Validate roleType configuration option is properly consumed by module definitions
  • Run existing unit and e2e test suites

* feature/swagger-edit-usermetadata: (29 commits)
  chore: udpate usermetadata for swagger
  v1.0.0-alpha.4
  chore: update user reponse dto
  v1.0.0-alpha.3
  chore: add type string to array
  chore: bump version to 1.0.0-alpha.2
  chore: update versions
  chore: update yarn
  chore: update invitation acceptance validations
  chore: linting
  chore: improve security on invitation flow
  chore: update for test:ci
  chore: codacy update
  chore: update versions
  chore: lint
  chore: fix tests
  chore: codacy lint
  chore: linting
  chore: update usermetadata
  chore: linting
  ...

Conflicts:
	examples/sample-server-auth/package.json
	examples/sample-server-auth/src/modules/user/dto/user-create.dto.ts
	examples/sample-server-auth/src/modules/user/dto/user-update.dto.ts
	examples/sample-server-auth/src/modules/user/dto/user.dto.ts
	examples/sample-server-auth/yarn.lock
	examples/sample-server/package.json
	examples/sample-server/yarn.lock
	lerna.json
	packages/rockets-server-auth/package.json
	packages/rockets-server-auth/src/domains/invitation/__tests__/invitation-flow.e2e-spec.ts
	packages/rockets-server-auth/src/domains/invitation/controllers/invitation.controller.ts
	packages/rockets-server-auth/src/domains/invitation/dto/rockets-auth-invitation-revoke.dto.ts
	packages/rockets-server-auth/src/domains/invitation/index.ts
	packages/rockets-server-auth/src/domains/invitation/interfaces/invitation-acceptance-data.interface.ts
	packages/rockets-server-auth/src/domains/role/services/rockets-auth-role.service.ts
	packages/rockets-server-auth/src/domains/user/modules/rockets-auth-signup.module.ts
	packages/rockets-server-auth/src/generate-swagger.ts
	packages/rockets-server-auth/src/shared/interfaces/rockets-auth-options-extras.interface.ts
	packages/rockets-server/package.json
	yarn.lock
@docs-page
Copy link
Copy Markdown

docs-page Bot commented Jan 29, 2026

To view this pull requests documentation preview, visit the following URL:

docs.page/btwld/rockets~20

Documentation is deployed and generated using docs.page.

@tnramalho tnramalho merged commit 4edc74f into btwld:main Jan 29, 2026
7 checks passed
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an authenticated “change my password” endpoint to rockets-server-auth and expands configurability/Swagger metadata across packages.

Changes:

  • Introduces MePasswordController (+ DTO + unit tests) and wires it into controller creation with a disable flag.
  • Enhances controller creation in rockets-server to support disabling specific controllers via extras.
  • Updates Swagger/DTO metadata and bumps package versions / example lockfiles.

Reviewed changes

Copilot reviewed 31 out of 35 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/rockets-server/src/rockets.module-definition.ts Adds controller selection logic with disableController support.
packages/rockets-server/src/rockets.module-definition.spec.ts Unit tests for controller selection/disable behavior.
packages/rockets-server/src/modules/user/user.dto.ts Updates user roles Swagger shape (userRoles) and supporting DTOs.
packages/rockets-server/src/interfaces/rockets-options-extras.interface.ts Adds disableController options interface and docs.
packages/rockets-server/src/index.ts Re-exports new extras interface types.
packages/rockets-server/package.json Version bump.
packages/rockets-server-auth/swagger/swagger.json Regenerated/expanded Swagger output.
packages/rockets-server-auth/src/shared/interfaces/rockets-auth-options-extras.interface.ts Adds mePassword controller disable flag.
packages/rockets-server-auth/src/rockets-auth.module-definition.ts Registers MePasswordController based on disable flags.
packages/rockets-server-auth/src/rockets-auth.module-definition.spec.ts Updates expected controller lists to include MePasswordController.
packages/rockets-server-auth/src/generate-swagger.ts Expands Swagger generation model/DTO setup for user metadata and invitations.
packages/rockets-server-auth/src/domains/user/modules/rockets-auth-admin.relations.e2e-spec.ts Adjusts e2e expectations around metadata validation (null vs empty string).
packages/rockets-server-auth/src/domains/user/dto/rockets-auth-user.dto.ts Adds userMetadata Swagger decorators on base user DTO.
packages/rockets-server-auth/src/domains/user/dto/rockets-auth-user-update.dto.ts Documentation update for overriding userMetadata.
packages/rockets-server-auth/src/domains/user/dto/rockets-auth-user-create.dto.ts Documentation update for overriding userMetadata.
packages/rockets-server-auth/src/domains/auth/index.ts Exports new controller + change-password DTO.
packages/rockets-server-auth/src/domains/auth/dto/rockets-auth-change-password.dto.ts New DTO for authenticated password change.
packages/rockets-server-auth/src/domains/auth/controllers/me-password.controller.ts New /me/password endpoint implementation.
packages/rockets-server-auth/src/domains/auth/controllers/me-password.controller.spec.ts Unit tests for password change flow.
packages/rockets-server-auth/src/fixtures/user/dto/rockets-auth-user-metadata.dto.fixture.ts Updates fixture metadata typing (nullable lastName).
packages/rockets-server-auth/src/fixtures/admin/app-module-admin-relations.fixture.ts Switches admin-relations fixture to use fixture DTOs.
packages/rockets-server-auth/package.json Version bump.
package.json Adds lodash dependency.
lerna.json Monorepo version bump.
examples/sample-server/yarn.lock Lockfile updates for bumped workspace package versions.
examples/sample-server/package.json Adds NestJS resolutions for examples.
examples/sample-server-auth/yarn.lock Lockfile updates for bumped workspace package versions.
examples/sample-server-auth/src/modules/user/dto/user.dto.ts Updates user DTO override pattern for userMetadata.
examples/sample-server-auth/src/modules/user/dto/user-update.dto.ts Updates user update DTO override pattern for userMetadata.
examples/sample-server-auth/src/modules/user/dto/user-create.dto.ts Updates user create DTO override pattern for userMetadata.
examples/sample-server-auth/package.json Adds/extends dependency resolutions (and lodash).
.gitignore Ignores generated SDK output folders.
.cursor/rules/testing.mdc Adds Cursor “testing rules” guidance file.
.claude/settings.local.json Expands allowed bash commands in Claude settings.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +33 to +80
@Controller('me')
@ApiTags('Me')
@ApiBearerAuth()
export class MePasswordController {
private readonly logger = new Logger(MePasswordController.name);

constructor(
@Inject(UserPasswordService)
private readonly userPasswordService: UserPasswordService,
@Inject(PasswordValidationService)
private readonly passwordValidationService: PasswordValidationService,
) {}

@Patch('password')
@HttpCode(200)
@Throttle({ default: { limit: 5, ttl: 60000 } })
@ApiOperation({
summary: 'Change password',
description:
'Allows authenticated user to change their own password by providing current and new password',
operationId: 'changeMyPassword',
})
@ApiBody({
type: RocketsAuthChangePasswordDto,
description: 'Current and new password',
examples: {
standard: {
value: {
currentPassword: 'CurrentP@ssw0rd',
newPassword: 'NewSecureP@ssw0rd',
},
summary: 'Standard password change',
},
},
})
@ApiOkResponse({
description: 'Password changed successfully',
})
@ApiUnauthorizedResponse({
description: 'Invalid current password or authentication token',
})
@ApiBadRequestResponse({
description: 'New password does not meet requirements',
})
async changePassword(
@AuthUser() user: RocketsAuthUserInterface,
@Body() changePasswordDto: RocketsAuthChangePasswordDto,
): Promise<void> {
Copy link

Copilot AI Jan 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MePasswordController does not apply any auth guard (e.g., AuthJwtGuard) and the rockets-auth module explicitly notes it doesn’t register a global AuthGuard. As a result, @authuser() will be undefined unless the host app adds a global/controller guard, leading to runtime errors on user.id and leaving the route effectively unauthenticated by default. Add an explicit JWT/auth guard on this controller/route (or wire enableGlobalJWTGuard into module providers) to ensure /me/password is protected.

Copilot uses AI. Check for mistakes.
tnramalho added a commit to tnramalho/rockets-sdk that referenced this pull request Jan 30, 2026
* main:
  feat(auth): add password change endpoint (btwld#20)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants