From f37d591f0a686de3838f9dad8f98d6aac0340c92 Mon Sep 17 00:00:00 2001 From: Dhruv Jain Date: Mon, 15 Mar 2021 00:16:05 +0530 Subject: [PATCH 1/6] [FIX] Migrate Github oauth to Github apps --- client/src/components/ActivityPane/index.js | 26 +--- client/src/components/CreateChannel/index.css | 10 +- client/src/components/CreateChannel/index.js | 125 ++++++------------ client/src/components/Home/index.js | 4 +- client/src/components/Login/index.js | 6 +- client/src/components/RoomInfo/index.js | 26 +--- client/src/utils/constants-example.js | 4 - server/config/constants_example.js | 12 +- server/controllers/login.js | 44 +----- server/controllers/webhooks.js | 13 +- server/routes/index.js | 1 - 11 files changed, 79 insertions(+), 192 deletions(-) diff --git a/client/src/components/ActivityPane/index.js b/client/src/components/ActivityPane/index.js index e394662..1a3fad6 100644 --- a/client/src/components/ActivityPane/index.js +++ b/client/src/components/ActivityPane/index.js @@ -5,10 +5,7 @@ import ActivityItem from "./../ActivityItem"; import MuiAlert from "@material-ui/lab/Alert"; import { Snackbar } from "@material-ui/core"; import ConfigureWebhook from "../ConfigureWebhook"; -import { - githubPrivateRepoAccessClientID, - githubApiDomain, -} from "../../utils/constants"; +import { githubApiDomain } from "../../utils/constants"; import { IoSettingsOutline } from "react-icons/io5"; import "./index.css"; @@ -81,14 +78,12 @@ export default function ActivityPane(props) { const repository = props.location.pathname .split("/")[2] .replace("_", "/"); - const authToken = - Cookies.get("gh_private_repo_token") || - Cookies.get("gh_login_token"); + const authToken = Cookies.get("gh_login_token"); const ghRepoResponse = await axios({ method: "get", url: `${githubApiDomain}/repos/${repository}`, headers: { - accept: "application/json", + accept: "application/vnd.github.v3+json", Authorization: `token ${authToken}`, }, }); @@ -98,7 +93,7 @@ export default function ActivityPane(props) { } catch (error) { console.log(error); } - } + }; checkIfUserIsOwner(); // eslint-disable-next-line }, [props.location.pathname]); @@ -118,15 +113,6 @@ export default function ActivityPane(props) { } }, [webhookId]); - const handleClickConfigureWebhooks = async () => { - if (!Cookies.get("gh_private_repo_token")) { - Cookies.set("gh_upgrade_prev_path", window.location.pathname); - window.location.href = `https://github.com/login/oauth/authorize?scope=repo&client_id=${githubPrivateRepoAccessClientID}`; - } else { - setOpenWebhookDialog(true); - } - }; - const setSnackbar = (snackbarSeverity, snackbarText) => { setSnackbarSeverity(snackbarSeverity); setSnackbarText(snackbarText); @@ -143,14 +129,14 @@ export default function ActivityPane(props) { return (
-
+
Activity {authState.isLoggedIn && isRepoOwner && (
setOpenWebhookDialog(true)} />
)} diff --git a/client/src/components/CreateChannel/index.css b/client/src/components/CreateChannel/index.css index 9c3792d..d80785a 100644 --- a/client/src/components/CreateChannel/index.css +++ b/client/src/components/CreateChannel/index.css @@ -24,4 +24,12 @@ .repository-select-label { margin-top: 0px; -} \ No newline at end of file + display: flex; + justify-content: space-between; +} + +.install-github-app-link { + /* text-transform: capitalize; */ + color: inherit; + text-decoration: underline; +} diff --git a/client/src/components/CreateChannel/index.js b/client/src/components/CreateChannel/index.js index bbacb75..0aaac52 100644 --- a/client/src/components/CreateChannel/index.js +++ b/client/src/components/CreateChannel/index.js @@ -13,11 +13,7 @@ import { } from "@material-ui/core"; import RCSwitch from "../RCSwitch"; import Cookies from "js-cookie"; -import { - githubPrivateRepoAccessClientID, - rcApiDomain, - rc4gitDomain, -} from "../../utils/constants"; +import { rcApiDomain, rc4gitDomain } from "../../utils/constants"; import EmbedBadgeDialog from "../EmbedBadgeDialog"; import "./index.css"; @@ -31,9 +27,6 @@ export default class CreateChannel extends Component { super(props); this.state = { repositories: [], - publicRepositories: [], - privateRepositories: [], - includePrivateRepositories: false, publicChannel: true, loading: false, channel: null, @@ -48,12 +41,9 @@ export default class CreateChannel extends Component { } handleClickChannelDialog = async () => { - const { publicRepositories, privateRepositories } = this.state; - - //Fetch public repositories - const publicRepoResponse = await axios({ + const getAllInstallations = await axios({ method: "get", - url: `https://api.github.com/user/repos?visibility=public&affiliation=owner,organization_member`, + url: `https://api.github.com/user/installations`, headers: { accept: "application/json", Authorization: `token ${Cookies.get("gh_login_token")}`, @@ -62,73 +52,50 @@ export default class CreateChannel extends Component { per_page: 100, }, }); - publicRepoResponse.data.map((repository) => - publicRepositories.push(repository.full_name) - ); - - if (Cookies.get("gh_private_repo_token")) { - const privateRepoResponse = await axios({ + let repositories = []; + for (const installation of getAllInstallations.data.installations) { + const fetchReposResponse = await axios({ method: "get", - url: `https://api.github.com/user/repos?visibility=private&affiliation=owner,organization_member`, + url: `https://api.github.com/user/installations/${installation.id}/repositories`, headers: { accept: "application/json", - Authorization: `token ${Cookies.get("gh_private_repo_token")}`, + Authorization: `token ${Cookies.get("gh_login_token")}`, }, params: { per_page: 100, }, }); - privateRepoResponse.data.map((repository) => - privateRepositories.push(repository.full_name) - ); - } - this.setState({ repositories: publicRepositories }); - }; - - handleAllRepositories = async (event) => { - const { publicRepositories, privateRepositories } = this.state; - this.setState({ ...this.state, [event.target.name]: event.target.checked }); - if (event.target.checked) { - if (!Cookies.get("gh_private_repo_token")) { - Cookies.set("gh_upgrade_prev_path", window.location.pathname); - window.location.href = `https://github.com/login/oauth/authorize?scope=repo&client_id=${githubPrivateRepoAccessClientID}`; - } - this.setState({ - repositories: publicRepositories.concat(privateRepositories), + fetchReposResponse.data.repositories.forEach((repo) => { + repositories.push(repo.full_name); }); - } else { - this.setState({ repositories: publicRepositories }); } + + this.setState({ repositories }); }; handleCreateChannel = async () => { const { channel, publicChannel } = this.state; const { setSnackbar, addRoom } = this.props; - const authToken = - Cookies.get("gh_private_repo_token") || Cookies.get("gh_login_token"); + const authToken = Cookies.get("gh_login_token"); let collaborators = [], description = ""; this.setState({ loading: true }); //Populate collaborators for the repo try { - // Fetching collaborators requires repo scope - if (Cookies.get("gh_private_repo_token")) { - const ghCollaboratorsResponse = await axios({ - method: "get", - url: `https://api.github.com/repos/${channel}/collaborators`, - headers: { - accept: "application/json", - Authorization: `token ${authToken}`, - }, - params: { - per_page: 100, - }, - }); - ghCollaboratorsResponse.data.map((member) => - collaborators.push(member.login.concat("_github_rc4git")) - ); - } - + const ghCollaboratorsResponse = await axios({ + method: "get", + url: `https://api.github.com/repos/${channel}/collaborators`, + headers: { + accept: "application/json", + Authorization: `token ${authToken}`, + }, + params: { + per_page: 100, + }, + }); + ghCollaboratorsResponse.data.map((member) => + collaborators.push(member.login.concat("_github_rc4git")) + ); const ghRepoResponse = await axios({ method: "get", url: `https://api.github.com/repos/${channel}`, @@ -204,7 +171,6 @@ Embed this room const { repositories, publicChannel, - includePrivateRepositories, channel, loading, room, @@ -232,7 +198,15 @@ Embed this room


-

Select Repository

+

+ Select Repository{" "} + + Add/Remove Repositories + +

)} -
-
-

Show All Repositories

- - } - /> -
- -

- {includePrivateRepositories - ? "Both public and private " - : "Only public "} - repositories are visible. -

-

Public Room


+

+ * All the repository collaborators who are RCforCommunity users + as well will automatically get added in the chat room. +

+
@@ -126,12 +127,13 @@ export default function Home(props) { search Discover existing rooms
- + community ); diff --git a/client/src/components/Login/index.js b/client/src/components/Login/index.js index 9b787eb..d2691b6 100644 --- a/client/src/components/Login/index.js +++ b/client/src/components/Login/index.js @@ -80,7 +80,7 @@ export default function Login(props) { ) : ( Login with github @@ -88,10 +88,6 @@ export default function Login(props) { )}
- {"By proceeding you are agreeing to our "} - Terms of Service,{" "} - Privacy Policy and{" "} - Legal Notice.
{"Powered by "}{" "} diff --git a/client/src/components/RoomInfo/index.js b/client/src/components/RoomInfo/index.js index c79e9de..1daf7ed 100644 --- a/client/src/components/RoomInfo/index.js +++ b/client/src/components/RoomInfo/index.js @@ -56,7 +56,7 @@ function a11yProps(index) { export default function RoomInfo(props) { const [repoInfo, setRepoInfo] = useState({}); const [isPrivate, setIsPrivate] = useState(false); - const [issuesCount, setIssuesCount] = useState(0); + const [issuesCount] = useState(0); const [isNotAccessible, setIsNotAccessible] = useState(false); const [roomMembers, setRoomMembers] = useState([]); const [openMembersDialog, setOpenMembersDialog] = useState(false); @@ -77,28 +77,14 @@ export default function RoomInfo(props) { .split("/")[2] .replace("_", "/"); const headers = { - accept: "application/json", + accept: "application/vnd.github.v3+json", + Authorization: `Token ${Cookies.get("gh_login_token")}`, }; - if (Cookies.get("gh_private_repo_token")) { - headers["Authorization"] = `token ${Cookies.get( - "gh_private_repo_token" - )}`; - } const ghRepoInfoResponse = await axios({ method: "get", url: `${githubApiDomain}/repos/${repository}`, headers: headers, }); - const ghIssuesResponse = await axios({ - method: "get", - url: `${githubApiDomain}/repos/${repository}/issues`, - headers: headers, - }); - // GitHub treats both PRs and issues as issues except that PRs can be - // distinguished by the presence of a pull_request key - setIssuesCount( - ghIssuesResponse.data.filter((issue) => !issue.pull_request).length - ); setRepoInfo(ghRepoInfoResponse.data); } catch (error) { console.log(error); @@ -156,12 +142,12 @@ export default function RoomInfo(props) { } } catch (error) { // User is logged out and not a member of the private room - console.log(error); setIsNotAccessible(true); } }; ghRepoInfo(); fetchRoomMembers(); + // eslint-disable-next-line }, [props.location.pathname]); const handleChange = (event, newValue) => { @@ -208,10 +194,11 @@ export default function RoomInfo(props) { xs={2} className="online-users-grid-item" > - + online {user.username} ); @@ -317,6 +304,7 @@ export default function RoomInfo(props) { {user.username}
{user.name} diff --git a/client/src/utils/constants-example.js b/client/src/utils/constants-example.js index 7176c4e..0f1d677 100644 --- a/client/src/utils/constants-example.js +++ b/client/src/utils/constants-example.js @@ -1,7 +1,4 @@ const githubClientID = process.env.GITHUB_CLIENT_ID || "YOUR_GITHUB_CLIENT_ID"; -const githubPrivateRepoAccessClientID = - process.env.GITHUB_PRIVATE_REPO_ACCESS_CLIENT_ID || - "YOUR_GITHUB_PRIVATE_REPO_ACCESS_CLIENT_ID"; const rcApiDomain = process.env.RC_API_DOMAIN || "YOUR_SELF_HOSTED_RC_API_DOMAIN"; const githubApiDomain = @@ -11,7 +8,6 @@ const rc4gitDomain = export { githubClientID, - githubPrivateRepoAccessClientID, rcApiDomain, githubApiDomain, rc4gitDomain diff --git a/server/config/constants_example.js b/server/config/constants_example.js index 221894f..e9edc0a 100644 --- a/server/config/constants_example.js +++ b/server/config/constants_example.js @@ -5,10 +5,6 @@ const iv = process.env.RC_PASS_CIPHER_IV || "YOUR IV"; const githubClientSecret = process.env.GITHUB_CLIENT_SECRET || "GH CLIENT SECRET"; const githubClientID = process.env.GITHUB_CLIENT_ID || "GH CLIENT ID"; -const githubPrivateRepoAccessClientSecret = - process.env.githubPrivateRepoAccessClientSecret || "GH CLIENT SECRET 2"; -const githubPrivateRepoAccessClientID = - process.env.githubPrivateRepoAccessClientID || "GH CLIENT ID 2"; const githubAuthURL = "https://github.com/login/oauth/access_token"; const githubAPIDomain = "https://api.github.com"; const rocketChatDomain = process.env.RC_DOMAIN || "http://localhost:3000"; @@ -16,7 +12,9 @@ const mongodbURI = process.env.MONGODB_URI || "mongodb://127.0.0.1/rc4git"; const rc4gitApiURL = process.env.RC4GIT_API_URL || "YOUR_PUBLICLY_HOSTED_RC4GIT_API_URL"; const rc_uid = process.env.RC_UID || "ROCKET.CHAT SERVER USER ID FOR STATS"; -const rc_token = process.env.RC_TOKEN || "ROCKET.CHAT SERVER USER TOKEN FOR STATS"; +const rc_token = + process.env.RC_TOKEN || "ROCKET.CHAT SERVER USER TOKEN FOR STATS"; + module.exports = { jwtSecret, algorithm, @@ -28,9 +26,7 @@ module.exports = { githubAPIDomain, rocketChatDomain, mongodbURI, - githubPrivateRepoAccessClientID, - githubPrivateRepoAccessClientSecret, rc4gitApiURL, rc_uid, - rc_token + rc_token, }; diff --git a/server/controllers/login.js b/server/controllers/login.js index 790f902..aee8726 100644 --- a/server/controllers/login.js +++ b/server/controllers/login.js @@ -18,14 +18,6 @@ module.exports.createToken = async function (req, res) { accept: "application/json", }, }); - //Check for permission scopes - const scope = ghTokenResponse.data.scope.split(","); - if (!scope.includes("read:org") || !scope.includes("user:email")) { - return res.status(401).json({ - success: false, - error: "More permissions are required", - }); - } //Fetch user email from github const ghUserEmailResponse = await axios({ @@ -149,7 +141,7 @@ module.exports.createToken = async function (req, res) { success: true, data: { rc_token: rcLoginUserResponse.data.data.authToken, - rc_uid: rcLoginUserResponse.data.data.userId, + rc_uid: rcLoginUserResponse.data.data.userId, rc4git_token: jwt.sign(userData, constants.jwtSecret), gh_login_token: ghTokenResponse.data.access_token, }, @@ -163,40 +155,6 @@ module.exports.createToken = async function (req, res) { } }; -module.exports.upgradeAccess = async (req, res) => { - try { - //Fetch access_token from github - const requestToken = req.body.code; - const ghTokenResponse = await axios({ - method: "post", - url: `${constants.githubAuthURL}?client_id=${constants.githubPrivateRepoAccessClientID}&client_secret=${constants.githubPrivateRepoAccessClientSecret}&code=${requestToken}`, - headers: { - accept: "application/json", - }, - }); - //Check for permission scopes - const scope = ghTokenResponse.data.scope.split(","); - if (!scope.includes("repo")) { - return res.status(401).json({ - success: false, - error: "Private Repo Access permissions are required", - }); - } - return res.status(200).json({ - success: true, - data: { - gh_private_repo_token: ghTokenResponse.data.access_token, - }, - }); - } catch (err) { - console.log(err); - return res.status(500).json({ - success: false, - error: `Internal Server Error ---> ${err}`, - }); - } -}; - module.exports.sso = (req, res) => { try { if (req.cookies["rc4git_token"] && req.cookies["rc_token"]) { diff --git a/server/controllers/webhooks.js b/server/controllers/webhooks.js index d7a0350..f20c9aa 100644 --- a/server/controllers/webhooks.js +++ b/server/controllers/webhooks.js @@ -122,13 +122,13 @@ module.exports.fetchWebhook = async (req, res) => { module.exports.createGithubWebhook = async (req, res) => { try { - if (req.cookies["gh_private_repo_token"]) { + if (req.cookies["gh_login_token"]) { const secret_token = Math.random().toString(36).slice(2) + Math.random().toString(36).toUpperCase().slice(2); const headers = { accept: "application/vnd.github.v3+json", - Authorization: `token ${req.cookies["gh_private_repo_token"]}`, + Authorization: `token ${req.cookies["gh_login_token"]}`, }; const config = { @@ -180,13 +180,13 @@ module.exports.createGithubWebhook = async (req, res) => { module.exports.updateGithubWebhook = async (req, res) => { try { - if (req.cookies["gh_private_repo_token"]) { + if (req.cookies["gh_login_token"]) { const hook = await githubWebhook.findOne({ hook_id: req.body.hook_id }); const secret_token = hook.secret_token; const headers = { accept: "application/vnd.github.v3+json", - Authorization: `token ${req.cookies["gh_private_repo_token"]}`, + Authorization: `token ${req.cookies["gh_login_token"]}`, }; const config = { @@ -231,10 +231,11 @@ module.exports.updateGithubWebhook = async (req, res) => { module.exports.deleteGithubWebhook = async (req, res) => { try { - if (req.cookies["gh_private_repo_token"]) { + if (req.cookies["gh_login_token"]) { + const headers = { accept: "application/vnd.github.v3+json", - Authorization: `token ${req.cookies["gh_private_repo_token"]}`, + Authorization: `token ${req.cookies["gh_login_token"]}`, }; const ghDeleteWebhookResponse = await axios({ diff --git a/server/routes/index.js b/server/routes/index.js index d99adbd..55b2145 100644 --- a/server/routes/index.js +++ b/server/routes/index.js @@ -9,7 +9,6 @@ const statsController = require("../controllers/stats"); const roomMembersController = require("../controllers/roomMembers"); router.post("/login", loginController.createToken); -router.post("/auth/github/upgrade", loginController.upgradeAccess); router.post("/sso", loginController.sso); router.get("/logout", loginController.logout); router.post("/createChannel", createChannelController); From 93f59cb10b0ec42abc2ef911eacf656065dad49a Mon Sep 17 00:00:00 2001 From: Dhruv Jain Date: Mon, 15 Mar 2021 19:20:25 +0530 Subject: [PATCH 2/6] [FIX] Overall code refactor and fix issues - Add warning note on public room creation for private repo - Fix two room items displayed for same room in sidebar on creating a new room - Add Github app slug constant - Fix check users for private room on fetching webhook id - Move roomMembers and create room to one controller --- client/public/index.html | 2 +- client/src/components/App.js | 4 +- client/src/components/ChatWindow/index.js | 2 +- .../src/components/ConfigureWebhook/index.js | 6 +- client/src/components/CreateChannel/index.js | 39 +++++--- client/src/components/Home/index.css | 2 +- client/src/components/Login/index.js | 2 +- client/src/components/RoomInfo/index.js | 1 + client/src/components/SidebarSearch/index.js | 4 +- .../src/components/SignedLeftSidebar/index.js | 2 +- client/src/utils/constants-example.js | 10 +- server/controllers/createChannel.js | 75 --------------- server/controllers/roomMembers.js | 24 ----- server/controllers/rooms.js | 91 +++++++++++++++++++ server/controllers/webhooks.js | 4 +- server/routes/index.js | 7 +- 16 files changed, 136 insertions(+), 139 deletions(-) delete mode 100644 server/controllers/createChannel.js delete mode 100644 server/controllers/roomMembers.js create mode 100644 server/controllers/rooms.js diff --git a/client/public/index.html b/client/public/index.html index e51a136..37bedb3 100644 --- a/client/public/index.html +++ b/client/public/index.html @@ -20,7 +20,7 @@ work correctly both with client-side routing and a non-root public URL. Learn how to configure a non-root public URL by running `npm run build`. --> - RC4Community + RCforCommunity diff --git a/client/src/components/App.js b/client/src/components/App.js index 86695bd..75f0e59 100644 --- a/client/src/components/App.js +++ b/client/src/components/App.js @@ -71,8 +71,8 @@ export default class App extends React.Component { stats: data.data }) }) - .catch((err) => { - console.log("Error logging out --->", err); + .catch((error) => { + console.log(error); return; }); } diff --git a/client/src/components/ChatWindow/index.js b/client/src/components/ChatWindow/index.js index 68d00f3..34fab22 100644 --- a/client/src/components/ChatWindow/index.js +++ b/client/src/components/ChatWindow/index.js @@ -16,7 +16,7 @@ export default function ChatWindow(props) { { externalCommand: "go", path: `${pathname}/?layout=embedded` }, `${rcApiDomain}` ); - }, [pathname]); + }, [props.location]); return (
{ const { channel, publicChannel } = this.state; - const { setSnackbar, addRoom } = this.props; + const { setSnackbar } = this.props; const authToken = Cookies.get("gh_login_token"); let collaborators = [], description = ""; @@ -94,7 +98,7 @@ export default class CreateChannel extends Component { }, }); ghCollaboratorsResponse.data.map((member) => - collaborators.push(member.login.concat("_github_rc4git")) + collaborators.push(member.login) ); const ghRepoResponse = await axios({ method: "get", @@ -105,9 +109,7 @@ export default class CreateChannel extends Component { }, }); - description = ghRepoResponse.data.description - ? ghRepoResponse.data.description - : ""; + description = ghRepoResponse.data.description || ""; const rcCreateChannelResponse = await axios({ method: "post", @@ -121,7 +123,7 @@ export default class CreateChannel extends Component { type: publicChannel ? "c" : "p", }, }); - if (rcCreateChannelResponse.data.data.success) { + if (publicChannel) { let room = rcCreateChannelResponse.data.data.channel; //Add embeddable code for room to description description = description.concat(` @@ -147,9 +149,6 @@ Embed this room description: description, }, }); - - addRoom(room); - setSnackbar(true, "success", "Room created successfully!"); this.setState({ loading: false, room: room, @@ -157,9 +156,12 @@ Embed this room showEmbedBadgeDialog: true, }); } else { - this.setState({ loading: false }); - setSnackbar(true, "error", "Error Creating Room!"); + this.setState({ + loading: false, + openCreateChannelDialog: false, + }); } + setSnackbar(true, "success", "Room created successfully!"); } catch (error) { console.log(error); this.setState({ loading: false }); @@ -201,7 +203,7 @@ Embed this room

Select Repository{" "} Add/Remove Repositories @@ -255,9 +257,16 @@ Embed this room : "Just invited people can access this room."}


+

Note:

+ {publicChannel && ( +

+ Public room for a private repository may expose the metadata + of that repository. +

+ )}

- * All the repository collaborators who are RCforCommunity users - as well will automatically get added in the chat room. + All the repository collaborators who are RCforCommunity users as + well will automatically get added in the chat room.


)} {webhookId && - events.map((event) => { + events.map((event, index) => { return ( From 281c1b873f133fc815d03a7cda832fae5380d1c8 Mon Sep 17 00:00:00 2001 From: Rohan Lekhwani Date: Mon, 15 Mar 2021 22:14:52 +0530 Subject: [PATCH 4/6] [REF] Removes room state from CreateChannel component --- client/src/components/CreateChannel/index.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/client/src/components/CreateChannel/index.js b/client/src/components/CreateChannel/index.js index 36bfb2f..9f42990 100644 --- a/client/src/components/CreateChannel/index.js +++ b/client/src/components/CreateChannel/index.js @@ -35,7 +35,6 @@ export default class CreateChannel extends Component { loading: false, channel: null, showEmbedBadgeDialog: false, - room: null, openCreateChannelDialog: true, }; } @@ -151,7 +150,6 @@ Embed this room }); this.setState({ loading: false, - room: room, openCreateChannelDialog: false, showEmbedBadgeDialog: true, }); @@ -175,7 +173,6 @@ Embed this room publicChannel, channel, loading, - room, openCreateChannelDialog, showEmbedBadgeDialog, } = this.state; @@ -286,7 +283,7 @@ Embed this room {showEmbedBadgeDialog && ( From 177ea0d1f59574b4b90e200d3e8e10399bb4df6d Mon Sep 17 00:00:00 2001 From: Rohan Lekhwani Date: Mon, 15 Mar 2021 22:15:12 +0530 Subject: [PATCH 5/6] [FIX] Inconsistent issues for public and private repositories --- client/src/components/RoomInfo/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/src/components/RoomInfo/index.js b/client/src/components/RoomInfo/index.js index 0795263..f6ca6bb 100644 --- a/client/src/components/RoomInfo/index.js +++ b/client/src/components/RoomInfo/index.js @@ -245,11 +245,11 @@ export default function RoomInfo(props) {
- {issuesCount} issues + {repoInfo.open_issues_count} issues From 2f666f7a0872fdb4efc21fe9f00460b41309a724 Mon Sep 17 00:00:00 2001 From: Rohan Lekhwani Date: Mon, 15 Mar 2021 22:32:04 +0530 Subject: [PATCH 6/6] [REF] Removes unused code, gh_private_repo_token --- client/src/components/CreateChannel/index.css | 1 - client/src/components/MainLayout/index.js | 30 ------------------- client/src/components/RoomInfo/index.js | 1 - .../src/components/SignedLeftSidebar/index.js | 1 - 4 files changed, 33 deletions(-) diff --git a/client/src/components/CreateChannel/index.css b/client/src/components/CreateChannel/index.css index d80785a..3c644b6 100644 --- a/client/src/components/CreateChannel/index.css +++ b/client/src/components/CreateChannel/index.css @@ -29,7 +29,6 @@ } .install-github-app-link { - /* text-transform: capitalize; */ color: inherit; text-decoration: underline; } diff --git a/client/src/components/MainLayout/index.js b/client/src/components/MainLayout/index.js index 670c1eb..ba87bbc 100644 --- a/client/src/components/MainLayout/index.js +++ b/client/src/components/MainLayout/index.js @@ -8,36 +8,6 @@ import RightSidebar from "./../RightSidebar"; import "./index.css"; export default function MainLayout(props) { - useEffect(() => { - const url = window.location.href; - const hasCode = url.includes("?code="); - - const proxy_url = `/api/auth/github/upgrade`; - - // If Github API returns the code parameter - if (hasCode) { - const newUrl = url.split("?code="); - - const requestData = { - code: newUrl[1], - }; - - fetch(proxy_url, { - method: "POST", - body: JSON.stringify(requestData), - headers: { - "Content-Type": "application/json", - }, - }) - .then((response) => response.json()) - .then((data) => { - Cookies.set("gh_private_repo_token", data.data.gh_private_repo_token); - window.location.href = - window.location.origin + Cookies.get("gh_upgrade_prev_path"); - }) - .catch((error) => console.log(error)); - } - }); const {authState, stats} = props; diff --git a/client/src/components/RoomInfo/index.js b/client/src/components/RoomInfo/index.js index f6ca6bb..5468608 100644 --- a/client/src/components/RoomInfo/index.js +++ b/client/src/components/RoomInfo/index.js @@ -56,7 +56,6 @@ function a11yProps(index) { export default function RoomInfo(props) { const [repoInfo, setRepoInfo] = useState({}); const [isPrivate, setIsPrivate] = useState(false); - const [issuesCount] = useState(0); const [isNotAccessible, setIsNotAccessible] = useState(false); const [roomMembers, setRoomMembers] = useState([]); const [openMembersDialog, setOpenMembersDialog] = useState(false); diff --git a/client/src/components/SignedLeftSidebar/index.js b/client/src/components/SignedLeftSidebar/index.js index 374c28c..d39f1d0 100644 --- a/client/src/components/SignedLeftSidebar/index.js +++ b/client/src/components/SignedLeftSidebar/index.js @@ -292,7 +292,6 @@ export default function SignedLeftSidebar(props) { Cookies.remove("rc_uid"); Cookies.remove("rc_token"); Cookies.remove("gh_login_token"); - Cookies.remove("gh_private_repo_token"); window.location = "/login"; }) .catch((err) => {