-
Notifications
You must be signed in to change notification settings - Fork 0
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
base: staging
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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]', |
There was a problem hiding this comment.
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; | |||
} |
There was a problem hiding this comment.
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') |
There was a problem hiding this comment.
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') |
There was a problem hiding this comment.
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') |
There was a problem hiding this comment.
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> { |
There was a problem hiding this comment.
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 }) |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
https://gfw.atlassian.net/browse/TM-1311