Skip to content

Commit

Permalink
feat: add member password routes (POST and update PATCH) (#1236)
Browse files Browse the repository at this point in the history
* feat: update member password repository to class

* feat: add create password route and update edit route

* fix: update tests

* fix: apply suggestion

Co-authored-by: Thibault Reidy <147397675+ReidyT@users.noreply.github.com>

* fix: use translation strings

* fix: login tests

---------

Co-authored-by: Thibault Reidy <147397675+ReidyT@users.noreply.github.com>
  • Loading branch information
spaenleh and ReidyT authored Jul 29, 2024
1 parent 6d6c2b9 commit 510cb8b
Show file tree
Hide file tree
Showing 15 changed files with 549 additions and 75 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@
"@fastify/static": "7.0.4",
"@fastify/websocket": "7.2.0",
"@graasp/etherpad-api": "2.1.1",
"@graasp/sdk": "4.21.0",
"@graasp/translations": "1.32.0",
"@graasp/sdk": "4.22.0",
"@graasp/translations": "1.32.1",
"@rapideditor/country-coder": "5.2.2",
"@sentry/node": "7.118.0",
"@sentry/tracing": "7.114.0",
Expand Down
3 changes: 2 additions & 1 deletion src/plugins/datasource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import { ItemMembership } from '../services/itemMembership/entities/ItemMembersh
import { Member } from '../services/member/entities/member';
import { MemberProfile } from '../services/member/plugins/profile/entities/profile';
import {
AUTO_RUN_MIGRATIONS,
DB_CONNECTION_POOL_SIZE,
DB_HOST,
DB_NAME,
Expand Down Expand Up @@ -66,7 +67,7 @@ export const AppDataSource = new DataSource({
// log queries that take more than 2s to execute
maxQueryExecutionTime: 2000,
logging: ['migration', 'error'],
migrationsRun: true,
migrationsRun: AUTO_RUN_MIGRATIONS,

entities: [
Member,
Expand Down
18 changes: 16 additions & 2 deletions src/services/auth/plugins/password/errors.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { StatusCodes } from 'http-status-codes';

import { ErrorFactory } from '@graasp/sdk';
import { FAILURE_MESSAGES } from '@graasp/translations';

export const GraaspPasswordError = ErrorFactory('graasp-plugin-password');

Expand All @@ -10,7 +11,7 @@ export class PasswordNotDefined extends GraaspPasswordError {
{
code: 'GPPWDERR001',
statusCode: StatusCodes.BAD_REQUEST,
message: 'password is not defined',
message: FAILURE_MESSAGES.PASSWORD_NOT_DEFINED_ERROR,
},
data,
);
Expand All @@ -23,7 +24,20 @@ export class PasswordNotStrong extends GraaspPasswordError {
{
code: 'GPPWDERR002',
statusCode: StatusCodes.BAD_REQUEST,
message: 'password is not strong enough',
message: FAILURE_MESSAGES.PASSWORD_WEAK_ERROR,
},
data,
);
}
}

export class PasswordConflict extends GraaspPasswordError {
constructor(data?: unknown) {
super(
{
code: 'GPPWDERR003',
statusCode: StatusCodes.CONFLICT,
message: FAILURE_MESSAGES.PASSWORD_CONFLICT_ERROR,
},
data,
);
Expand Down
Loading

0 comments on commit 510cb8b

Please sign in to comment.