Skip to content

Commit

Permalink
changed post method to patch
Browse files Browse the repository at this point in the history
  • Loading branch information
javtran committed Aug 23, 2024
1 parent 4d2b976 commit 756c758
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion client/src/pages/auth/password-forgot/passwordForgot.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function PasswordForgot() {
setEmailError(null);
setIsLoading(true);
fetch('/api/v1/users/request-password-reset', {
method: 'POST',
method: 'PATCH',
headers: {
'Content-Type': 'application/json',
},
Expand Down
2 changes: 1 addition & 1 deletion server/routes/api/v1/users/password-reset.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { StatusCodes } from 'http-status-codes';
import User from '../../../../models/user.js';

export default async function (fastify, _opts) {
fastify.post(
fastify.patch(
'/password-reset',
{
schema: {
Expand Down
2 changes: 1 addition & 1 deletion server/routes/api/v1/users/request-password-reset.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { StatusCodes } from 'http-status-codes';
import User from '../../../../models/user.js';

export default async function (fastify, _opts) {
fastify.post(
fastify.patch(
'/request-password-reset',
{
schema: {
Expand Down
14 changes: 7 additions & 7 deletions server/test/routes/api/v1/users.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -696,14 +696,14 @@ describe('/api/v1/users', () => {
});
});

describe('POST /request-password-reset', () => {
describe('PATCH /request-password-reset', () => {
it('should allow user to request a password reset', async (t) => {
const app = await build(t);
await t.loadFixtures();

const res = await app
.inject()
.post('/api/v1/users/request-password-reset')
.patch('/api/v1/users/request-password-reset')
.payload({
email: '[email protected]',
});
Expand All @@ -729,7 +729,7 @@ describe('/api/v1/users', () => {

const res = await app
.inject()
.post('/api/v1/users/request-password-reset')
.patch('/api/v1/users/request-password-reset')
.payload({
email: '[email protected]',
});
Expand Down Expand Up @@ -797,14 +797,14 @@ describe('/api/v1/users', () => {
});
});

describe('POST /password-reset', () => {
describe('PATCH /password-reset', () => {
it('should return status OK on successful password reset', async (t) => {
const app = await build(t);
await t.loadFixtures();

const res = await app
.inject()
.post('/api/v1/users/password-reset')
.patch('/api/v1/users/password-reset')
.payload({
passwordResetToken: '4ae4a190-005e-4222-aac3-7dd5ff2c477f',
password: 'NewPassword123!',
Expand Down Expand Up @@ -834,15 +834,15 @@ describe('/api/v1/users', () => {

let res = await app
.inject()
.post('/api/v1/users/password-reset')
.patch('/api/v1/users/password-reset')
.payload({
passwordResetToken: '4ae4a190-005e-4222-aac3-7dd5ff2c477f',
password: 'NewPassword123!',
});

assert.deepStrictEqual(res.statusCode, StatusCodes.OK);

res = await app.inject().post('/api/v1/users/password-reset').payload({
res = await app.inject().patch('/api/v1/users/password-reset').payload({
passwordResetToken: '4ae4a190-005e-4222-aac3-7dd5ff2c477f',
password: 'AnotherPassword123!',
});
Expand Down

0 comments on commit 756c758

Please sign in to comment.