Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TM-1311] Implement password reset #46

Open
wants to merge 3 commits into
base: staging
Choose a base branch
from

Conversation

Scriptmatico
Copy link
Collaborator

@Scriptmatico Scriptmatico commented Jan 22, 2025

@Scriptmatico Scriptmatico requested a review from roguenet January 22, 2025 02:18
Copy link
Collaborator

@roguenet roguenet left a comment

Choose a reason for hiding this comment

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

I don't see any specs in this PR. Please ensure you have specs for all new controllers and services that pass our global coverage configuration.

@ApiProperty({
description:
'User email',
example: '[email protected]',
Copy link
Collaborator

Choose a reason for hiding this comment

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

I haven't seen how this is used yet, but this description / example doesn't seem right for a property named message.

@@ -0,0 +1,3 @@
export class ResetPasswordDto {
newPassword: string;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

This should have some validation on it. See login-request.dto.ts for an example.

import { NoBearerAuth } from '@terramatch-microservices/common/guards';
import { ResetPasswordResponseOperationDto } from "./dto/reset-password-response-operation.dto";

@Controller('auth/v3/reset-password')
Copy link
Collaborator

Choose a reason for hiding this comment

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

For resource named endpoints in this codebase, they should be camel case and plural. I would probably call this passwordResets.

export class ResetPasswordController {
constructor(private readonly resetPasswordService: ResetPasswordService) {}

@Post('request')
Copy link
Collaborator

Choose a reason for hiding this comment

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

When creating a resource (in the case of this controller, a password reset), it's more typical in REST to post directly to the root resource path. So, this would be simply Post(), and the client will then issue a POST to auth/v3/passwordResets as a create action.

.document.serialize();
}

@Post('reset/:token')
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it would follow REST conventions better if this were @Put(':token'). Symantically, that would mean that you're updating the given passwordReset resource, which aligns a little better with REST for this kind of weird virtual resource.



@Table({ tableName: "localization_keys", underscored: true, paranoid: false })
export class LocalizationKeys extends Model<LocalizationKeys> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

The convention in laravel is to have the database table name be pluralized, but in this codebase all entities are singular: LocalizationKey




@Table({ tableName: "localization_keys", underscored: true, paranoid: false })
Copy link
Collaborator

Choose a reason for hiding this comment

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

paranoid: false is the default and may be left out of this config.

@Column(STRING)
key: string | null;

@AllowNull
Copy link
Collaborator

Choose a reason for hiding this comment

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

According to the current DB schema, key and value are not allowed to be null. Please try to follow the current schema as closely as possible when defining columns in this codebase.

key: string | null;

@AllowNull
@Column(STRING)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This column appears to be a TEXT type, not STRING in the DB (text vs varchar(255))

value: string | null;

@AllowNull
@Unique
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not sure if these value ids are required to be unique or not, but I do see that the current DB schema doesn't set a uniqueness constraint on this column, so we shouldn't here either.

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.

2 participants