-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
♻️ refactor(validations): centralize no allowed on demo validations
- Loading branch information
1 parent
0b63397
commit feea583
Showing
20 changed files
with
113 additions
and
218 deletions.
There are no files selected for viewing
83 changes: 0 additions & 83 deletions
83
src/backend/dashboard-widgets/dashboard-widgets.controller.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
src/backend/lib/request/validations/implementations/not-allowed-on-demo.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { BadRequestError } from "backend/lib/errors"; | ||
import { ValidationImplType } from "./types"; | ||
|
||
export const notAllowedOnDemoValidationImpl: ValidationImplType< | ||
void | ||
> = async () => { | ||
if (process.env.NEXT_PUBLIC_IS_DEMO) { | ||
throw new BadRequestError("This service is not available on the demo site"); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,27 @@ | ||
import { usersApiController } from "backend/users/users.controller"; | ||
import { CHANGE_PASSWORD_FORM_SCHEMA } from "shared/form-schemas/profile/password"; | ||
import { IAccountProfile } from "shared/types/user"; | ||
import { requestHandler } from "backend/lib/request"; | ||
import { usersApiService } from "backend/users/users.service"; | ||
|
||
export default requestHandler({ | ||
PATCH: async (getValidatedRequest) => { | ||
const validatedRequest = await getValidatedRequest([ | ||
"authenticatedUser", | ||
{ | ||
_type: "requestBody", | ||
options: CHANGE_PASSWORD_FORM_SCHEMA, | ||
}, | ||
]); | ||
return await usersApiController.updatePassword( | ||
(validatedRequest.authenticatedUser as IAccountProfile).username, | ||
validatedRequest.requestBody | ||
); | ||
export default requestHandler( | ||
{ | ||
PATCH: async (getValidatedRequest) => { | ||
const validatedRequest = await getValidatedRequest([ | ||
"authenticatedUser", | ||
{ | ||
_type: "requestBody", | ||
options: CHANGE_PASSWORD_FORM_SCHEMA, | ||
}, | ||
]); | ||
return await usersApiService.changePassword( | ||
(validatedRequest.authenticatedUser as IAccountProfile).username, | ||
validatedRequest.requestBody | ||
); | ||
}, | ||
}, | ||
}); | ||
[ | ||
{ | ||
_type: "notAllowedOnDemo", | ||
}, | ||
] | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.