3769 - Differentiate forbidden and unauthenticated - add product group filter (#153)
This commit is contained in:
+1
-1
@@ -12,4 +12,4 @@ ENV NEW_RELIC_NO_CONFIG_FILE=true
|
||||
# Installs npm dependencies on container
|
||||
RUN npm ci
|
||||
# Command container will actually run when called
|
||||
CMD ["npx", "nodemon", "-w", "src", "--ext", "ts", "--exec", "TZ=Europe/Paris", "ts-node", "src/index.ts"]
|
||||
CMD ["npx", "nodemon", "--exec", "TZ=Europe/Paris", "ts-node", "src/index.ts"]
|
||||
|
||||
+1
-1
@@ -9,4 +9,4 @@ WORKDIR /app
|
||||
ENV NODE_ENV=development
|
||||
ENV NEW_RELIC_NO_CONFIG_FILE=true
|
||||
# Command container will actually run when called
|
||||
CMD ["npx", "nodemon", "-w", "src", "--ext", "ts", "--exec", "TZ=Europe/Paris", "ts-node", "src/index.ts"]
|
||||
CMD ["npx", "nodemon", "-w", "src", "--ext", "ts, graphql", "--exec", "TZ=Europe/Paris", "ts-node", "src/index.ts"]
|
||||
|
||||
@@ -23,7 +23,7 @@ COGNITO_LOGIN_CLIENT_ID and COGNITO_LOGIN_CLIENT_SECRET found in cognito `photow
|
||||
|
||||
### Development
|
||||
|
||||
This project runs in docker, so when developing start the docker environment and it will restart automatically when files are changed. Sometimes the watch for files doesn't trigger. Like when you edit the .graphql file. Then just edit a .ts file and it will reload.
|
||||
This project runs in docker, so when developing start the docker environment and it will restart automatically when .graphql (schema) or .ts files are changed.
|
||||
|
||||
Run
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ function throwForbidden() {
|
||||
extensions: {
|
||||
code: 'FORBIDDEN',
|
||||
http: {
|
||||
status: 401,
|
||||
status: 403,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@@ -187,7 +187,7 @@ const verifyAuthentication = async (req: IncomingMessage) => {
|
||||
const notAuthorizedError = () => {
|
||||
throw new GraphQLError('You are not authorized', {
|
||||
extensions: {
|
||||
code: 'FORBIDDEN',
|
||||
code: 'UNAUTHENTICATED',
|
||||
http: {
|
||||
status: 401,
|
||||
},
|
||||
|
||||
@@ -3,6 +3,7 @@ import {
|
||||
Orientation,
|
||||
PrintProduct,
|
||||
Product,
|
||||
ProductGroup,
|
||||
ProductListResult,
|
||||
ProductsFilterInput,
|
||||
ProductsSearchResult,
|
||||
@@ -32,6 +33,17 @@ const ProductBlacklist = {
|
||||
};
|
||||
|
||||
const Product = {
|
||||
async printProducts(
|
||||
product: { printProducts: PrintProduct[] },
|
||||
input: { groups: ProductGroup[] },
|
||||
) {
|
||||
if (!input.groups) {
|
||||
return product.printProducts;
|
||||
}
|
||||
return product.printProducts.filter((printProduct) => {
|
||||
return input.groups.includes(printProduct.group);
|
||||
});
|
||||
},
|
||||
async categories({ id }, _args, { dataSources }): Promise<Array<Category>> {
|
||||
return (<CategoryAPI>dataSources.categoryApi).getProductCategories(id);
|
||||
},
|
||||
|
||||
+1
-1
@@ -254,7 +254,7 @@ type Product {
|
||||
inserted: DateTime!
|
||||
updated: DateTime
|
||||
publishingDate: DateTime!
|
||||
printProducts: [PrintProduct]
|
||||
printProducts(groups: [ProductGroup]): [PrintProduct]
|
||||
blacklisting: [ProductBlacklist]
|
||||
categories: [Category]
|
||||
designerId: Int
|
||||
|
||||
Reference in New Issue
Block a user