Skip to content

Commit

Permalink
fix(eslint): message,index,googleOAuth.controller
Browse files Browse the repository at this point in the history
fixing #108
  • Loading branch information
roman-ojha committed Jun 19, 2022
1 parent 3a3b35b commit f2b8f5c
Show file tree
Hide file tree
Showing 9 changed files with 159 additions and 132 deletions.
14 changes: 12 additions & 2 deletions .eslintrc.json
Expand Up @@ -15,13 +15,23 @@
"jsx": true
},
"ecmaVersion": "latest",
"sourceType": "module"
"sourceType": "module",
"project": "./tsconfig.json"
},
"plugins": ["react", "@typescript-eslint"],
"ignorePatterns": ["dist/", "node_modules/"],
"rules": {
// "semi": ["error", "always"],
"linebreak-style": 0,
"quotes": ["error", "double"]
"quotes": ["error", "double"],
"comma-dangle": ["error", "never"],
"max-len": "off"
},
"settings": {
"import/resolver": {
"node": {
"extensions": [".js", ".jsx", ".ts", ".tsx"]
}
}
}
}
2 changes: 1 addition & 1 deletion .prettierrc.json
@@ -1,5 +1,5 @@
{
"trailingComma": "es5",
"trailingComma": "none",
"tabWidth": 2,
"semi": true,
"singleQuote": false,
Expand Down
24 changes: 12 additions & 12 deletions client/src/components/CommentBox.jsx
Expand Up @@ -9,7 +9,7 @@ import {
startProgressBar,
stopProgressBar,
setRootUserProfileDataState,
profilePageDataAction,
profilePageDataAction
} from "../services/redux-actions";
import { useState } from "react";
import User_Profile_Icon from "../assets/svg/User_profile_Icon.svg";
Expand Down Expand Up @@ -45,7 +45,7 @@ const ReturnCommentContent = () => {
commentBoxAction({
openCommentBox: false,
postID: "",
to: "",
to: ""
})
);
}
Expand All @@ -62,7 +62,7 @@ const ReturnCommentContent = () => {
comment: commentInputFieldData,
postID: commentBoxStore.postID,
toId: commentBoxStore.toId,
toUserId: commentBoxStore.toUserId,
toUserId: commentBoxStore.toUserId
});

const data = await res.data;
Expand All @@ -72,7 +72,7 @@ const ReturnCommentContent = () => {
dispatch(
incrementPostCommentNumber({
postID: commentBoxStore.postID,
to: commentBoxStore.to,
to: commentBoxStore.to
})
);
dispatch(
Expand All @@ -83,7 +83,7 @@ const ReturnCommentContent = () => {
toUserId: commentBoxStore.toUserId,
commented: true,
newComment: commentInputFieldData,
comments: [],
comments: []
})
);
toastSuccess(data.msg);
Expand Down Expand Up @@ -112,14 +112,14 @@ const ReturnCommentContent = () => {
// success
const userObj = {
...userData.searchedUser,
isRootUserFollowed: userData.isRootUserFollowed,
isRootUserFollowed: userData.isRootUserFollowed
};
dispatch(profilePageDataAction(userObj));
if (userID === userProfileDetailStore.userID) {
dispatch(
setRootUserProfileDataState({
fetchedRootUserProfileData: true,
getRootUserProfileData: false,
getRootUserProfileData: false
})
);
}
Expand Down Expand Up @@ -155,7 +155,7 @@ const ReturnCommentContent = () => {
commentBoxAction({
openCommentBox: false,
postID: "",
to: "",
to: ""
})
);
}}
Expand All @@ -168,7 +168,7 @@ const ReturnCommentContent = () => {
commentBoxAction({
openCommentBox: false,
postID: "",
to: "",
to: ""
})
);
}}
Expand Down Expand Up @@ -197,14 +197,14 @@ const ReturnCommentContent = () => {
onClick={() => {
const userObj = {
...userProfileDetailStore,
isRootUserFollowed: false,
isRootUserFollowed: false
};
dispatch(profilePageDataAction(userObj));
if (!rootUserProfileDataState.fetchedRootUserProfileData) {
dispatch(
setRootUserProfileDataState({
fetchedRootUserProfileData: false,
getRootUserProfileData: true,
getRootUserProfileData: true
})
);
}
Expand All @@ -216,7 +216,7 @@ const ReturnCommentContent = () => {
toUserId: "",
commented: false,
newComment: "",
comments: [],
comments: []
})
);
history.push(
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/DefaultSocialPost.jsx
Expand Up @@ -6,7 +6,7 @@ import { useMediaQuery } from "react-responsive";

const DefaultSocialPost = () => {
const isMax850px = useMediaQuery({
query: `(max-width:${constant.mediaQueryRes.screen850}px)`,
query: `(max-width:${constant.mediaQueryRes.screen850}px)`
});
return (
<>
Expand Down
29 changes: 19 additions & 10 deletions controllers/googleOAuth.controller.ts
@@ -1,8 +1,10 @@
/* eslint-disable import/no-unresolved */
import UserDetail from "../models/userDetail_model.js";
const CLIENT_BASE_URL = process.env.CLIENT_BASE_URL;
import { __prod__ } from "../constants/env.js";
// import { __prod__ } from "../constants/env.js";
// import { Request, Response } from "express";

const { CLIENT_BASE_URL } = process.env;

export default {
loginSuccess: async (req, res) => {
// here if user login form google after that we are finding the email of that on data base and generating token for that user and after that store that token in cookie
Expand All @@ -15,7 +17,7 @@ export default {
userID: 1,
name: 1,
picture: 1,
tokens: 1,
tokens: 1
}
);
if (userLogin) {
Expand All @@ -27,24 +29,31 @@ export default {
domain: process.env.ORIGIN_HOSTNAME,
secure: true,
// signed: true,
sameSite: "none",
sameSite: "none"
});
}
// NOTE: if we would hosted client app on vercel and server on heroku and Cookies are not cross-domain compatible. if it was, it would be a serious security issue. So that we have to pass the token as response object
if (userLogin.userID === undefined) {
return res.redirect(`${CLIENT_BASE_URL}/userid?uid=undefined`);
} else {
return res.redirect(`${CLIENT_BASE_URL}/userid`);
}
return res.redirect(`${CLIENT_BASE_URL}/userid`);
}
return res.status(401).json("UnAuthorized");
} catch (err) {}
} catch (err) {
return res
.status(500)
.json({ error: "Server Error!!, Please Try again later" });
}
},
loginFail: (req, res) => {
try {
res
return res
.status(401)
.json({ error: "Something went wrong, try again letter..." });
} catch (err) {}
},
} catch (err) {
return res
.status(500)
.json({ error: "Server Error!!, Please Try again later" });
}
}
};
5 changes: 3 additions & 2 deletions controllers/index.controller.ts
@@ -1,3 +1,4 @@
/* eslint-disable import/no-unresolved */
import { Request, Response } from "express";
import ResponseObject from "../interface/responseObject.js";

Expand All @@ -8,8 +9,8 @@ export default {
} catch (err) {
return res.status(500).json(<ResponseObject>{
success: false,
msg: "Server Error, please try again later",
msg: "Server Error, please try again later"
});
}
},
}
};

0 comments on commit f2b8f5c

Please sign in to comment.