sdy

create new middleware

...@@ -16,6 +16,13 @@ export const getUserId = (context) => { ...@@ -16,6 +16,13 @@ export const getUserId = (context) => {
16 throw new Error("There is no vaild user"); 16 throw new Error("There is no vaild user");
17 }; 17 };
18 18
19 +export const isAuthenticated = (request) => {
20 + if (!request.user) {
21 + throw new Error("You need to login First");
22 + }
23 + return;
24 +};
25 +
19 export const generateSecret = () => { 26 export const generateSecret = () => {
20 const randomNumber = Math.floor(Math.random() * adjectives.length); 27 const randomNumber = Math.floor(Math.random() * adjectives.length);
21 return `${adjectives[randomNumber]} ${nouns[randomNumber]}`; 28 return `${adjectives[randomNumber]} ${nouns[randomNumber]}`;
......