-
Notifications
You must be signed in to change notification settings - Fork 3
Ps 513 hotfix #49
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
Ps 513 hotfix #49
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -286,6 +286,8 @@ paths: | |
| description: |- | ||
| Update the member profile by handle. | ||
|
|
||
| Handle updates are not supported on this endpoint. Use `PATCH /members/{handle}/change_handle` to change handles. | ||
|
|
||
| If the email has been changed, the email change process starts and a verification email is sent to the new and old email address. | ||
|
|
||
| Authorization: | ||
|
|
@@ -332,6 +334,59 @@ paths: | |
| description: Internal server error | ||
| schema: | ||
| $ref: '#/definitions/ErrorModel' | ||
| '/members/{handle}/change_handle': | ||
| patch: | ||
| tags: | ||
| - Basic | ||
| description: |- | ||
| Update the member handle. | ||
|
|
||
| Authorization: | ||
| - JWT roles: Only the profile owner or users with `administrator`/`admin` roles may update member data. | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [ |
||
| - M2M scopes: `update:user_profiles` or `all:user_profiles`. | ||
| security: | ||
| - bearer: [] | ||
| parameters: | ||
| - in: path | ||
| name: handle | ||
| required: true | ||
| type: string | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [ |
||
| - in: query | ||
| name: fields | ||
| required: false | ||
| type: string | ||
| description: > | ||
| Comma separated list of fields to include in the response. Defaults to all member fields. | ||
| - in: body | ||
| name: body | ||
| required: true | ||
| schema: | ||
| $ref: '#/definitions/MemberHandleUpdate' | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [ |
||
| responses: | ||
| '200': | ||
| description: OK | ||
| schema: | ||
| $ref: '#/definitions/MemberProfile' | ||
| '400': | ||
| description: Bad request data | ||
| schema: | ||
| $ref: '#/definitions/ErrorModel' | ||
| '401': | ||
| description: Miss or wrong authentication credentials | ||
| schema: | ||
| $ref: '#/definitions/ErrorModel' | ||
| '403': | ||
| description: No permission | ||
| schema: | ||
| $ref: '#/definitions/ErrorModel' | ||
| '404': | ||
| description: Not found | ||
| schema: | ||
| $ref: '#/definitions/ErrorModel' | ||
| '500': | ||
| description: Internal server error | ||
| schema: | ||
| $ref: '#/definitions/ErrorModel' | ||
| '/members/{handle}/profileCompleteness': | ||
| get: | ||
| tags: | ||
|
|
@@ -1793,6 +1848,14 @@ definitions: | |
| description: 'ISO-8601 formatted date times (YYYY-MM-DDTHH:mm:ss.sssZ)' | ||
| updatedBy: | ||
| type: string | ||
| MemberHandleUpdate: | ||
| type: object | ||
| required: | ||
| - newHandle | ||
| properties: | ||
| newHandle: | ||
| type: string | ||
| description: New handle for the member. | ||
| EmailVerificationResult: | ||
| type: object | ||
| properties: | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| const config = require('config') | ||
| const mysql = require('mysql2/promise') | ||
| const errors = require('./errors') | ||
|
|
||
| let vanillaPool | ||
|
|
||
| function getVanillaPool () { | ||
| if (!config.VANILLA_DB_URL) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [ |
||
| throw new errors.BadRequestError('VANILLA_DB_URL is not configured') | ||
| } | ||
|
|
||
| if (!vanillaPool) { | ||
| vanillaPool = mysql.createPool(config.VANILLA_DB_URL) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [ |
||
| } | ||
|
|
||
| return vanillaPool | ||
| } | ||
|
|
||
| module.exports = { | ||
| getVanillaPool | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -42,6 +42,16 @@ async function updateMember (req, res) { | |
| res.send(result) | ||
| } | ||
|
|
||
| /** | ||
| * Update member handle | ||
| * @param {Object} req the request | ||
| * @param {Object} res the response | ||
| */ | ||
| async function updateHandle (req, res) { | ||
| const result = await service.updateHandle(req.authUser, req.params.handle, req.query, req.body) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [❗❗ |
||
| res.send(result) | ||
| } | ||
|
|
||
| /** | ||
| * Verify email | ||
| * @param {Object} req the request | ||
|
|
@@ -77,6 +87,7 @@ module.exports = { | |
| getProfileCompleteness, | ||
| getMemberUserIdSignature, | ||
| updateMember, | ||
| updateHandle, | ||
| verifyEmail, | ||
| uploadPhoto, | ||
| deleteMember | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -81,6 +81,15 @@ module.exports = { | |
| access: constants.ADMIN_ROLES | ||
| } | ||
| }, | ||
| '/members/:handle/change_handle': { | ||
| patch: { | ||
| controller: 'MemberController', | ||
| method: 'updateHandle', | ||
| auth: 'jwt', | ||
| access: constants.ADMIN_ROLES, | ||
| scopes: [MEMBERS.UPDATE, MEMBERS.ALL] | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [ |
||
| } | ||
| }, | ||
| '/members/:handle/profileCompleteness': { | ||
| get: { | ||
| controller: 'MemberController', | ||
|
|
||
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.
[❗❗
security]Ensure that
VANILLA_DB_URLis properly validated and sanitized before use to prevent potential security vulnerabilities such as SQL injection.