Skip to content

Commit d8a3cf0

Browse files
committed
Added oAuth by Github
Added requested changes Changed oauth credentials Added a third party proxy to bypass cors errors Added access token extractor switched to environment variables Delete .env.local Added setup steps in readme
1 parent 0420153 commit d8a3cf0

File tree

7 files changed

+30
-14
lines changed

7 files changed

+30
-14
lines changed

README.md

+11
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,17 @@ The other part of this project includes the “notifying moderator” since we s
2626

2727
For instance, suppose a contributor “X” has been quite active within the community by working on various PRs, opening and resolving various issues, active on chat channels but after a month “X” gets disappeared. So by using this dashboard they will have a badge interface. There will be a badge attached in front of the name of the contributor. Let the name of the badge be “Y” so this badge will have a unique color. So as the time passes like “ a day went, 1 week went, 2 weeks went, a month, etc) this badges will get keep on fading. And Every fade color will have a unique reason. For example, when a contributor made a PR, the badge appeared “Red” in color. This badge will remain in the same color as long as he/she is contributing. Assume that contributor stops contributing and has not contributed for a week so his badge will become green in color. And this will keep on notifying mainaters, Admins about their disappearing. This way the organisations will have greater eye on the contributors and can help them sustain with the community.
2828

29+
## Setting up the project
30+
To set up the project, carry out the following steps:
31+
- Clone/download the project locally
32+
- Create an [oAuth](https://github.com/settings/developers) application if you haven't already
33+
- Make sure that the callback-url is set to `http://localhost:8080/#/auth`
34+
- Make an `.env` file in the root folder of the project (where package.json is)
35+
- Add the code given below and replace it with values from your oAuth application:
36+
`VUE_APP_CLIENT_ID=<client id>`
37+
`VUE_APP_CLIENT_SECRET=<client secret>`
38+
- Run the app using `npm start serve`
39+
2940
## Stack used
3041

3142
This will have a dashboard, where these things can be placed. The stack used can be any but since the organisation have fixed stack so its better to stick to Nodejs, Vue, React.

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"dependencies": {
1111
"axios": "^0.18.0",
1212
"core-js": "^2.6.5",
13+
"cors": "^2.8.5",
1314
"vue": "^2.6.10",
1415
"vue-router": "^3.0.3",
1516
"vuetify": "^1.5.5",

public/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
66
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
77
<link rel="icon" href="<%= BASE_URL %>favicon.ico" />
8-
<title>codebadge</title>
8+
<title>CodeBadge</title>
99
<link
1010
rel="stylesheet"
1111
href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900"

src/components/auth/Login.vue

+14-7
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
<script>
1616
import axios from 'axios';
17-
import AuthHelper from '../../config/AuthHelper';
1817
import AxiosHelper from '../../config/AxiosHelper';
1918
2019
export default {
@@ -27,19 +26,27 @@ export default {
2726
methods: {
2827
login() {
2928
window.location = `${AxiosHelper.authUrl}?client_id=${
30-
AuthHelper.clientId
29+
process.env.VUE_APP_CLIENT_ID
3130
}&scope=user%20repo%20read:org`;
3231
}
3332
},
34-
created() {
33+
created: function() {
3534
const code = window.location.href.match(/\?code=(.*)/);
3635
if (code) {
3736
this.isLoading = true;
38-
axios
39-
.get(`${AxiosHelper.gatekeeperUrl}/${code[1].slice(0, 20)}`)
40-
.then(res => {
37+
console.log(this.isLoading);
38+
axios({
39+
method: `post`,
40+
url: `${AxiosHelper.gatekeeperUrl}?client_id=${
41+
process.env.VUE_APP_CLIENT_ID
42+
}&client_secret=${
43+
process.env.VUE_APP_CLIENT_SECRET
44+
}&code=${code[1].slice(0, 20)}`
45+
}).then(res => {
4146
this.isLoading = false;
42-
localStorage.setItem('token', res.data.token);
47+
var token = res.data.match(/access_token=(.*)/)[1].slice(0,40);
48+
console.log("access_token:" + token);
49+
localStorage.setItem('token', token);
4350
window.location = AxiosHelper.homeUrl;
4451
})
4552
.catch(err => {

src/config/AuthHelper.js

-3
This file was deleted.

src/config/AxiosHelper.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module.exports = {
22
baseUrl: 'https://api.github.com',
33
authUrl: 'https://github.com/login/oauth/authorize',
4-
gatekeeperUrl: 'https://gatekeeper-oauth.herokuapp.com/authenticate',
5-
homeUrl: 'http://prabhani.me/Codebadge/#/home'
4+
gatekeeperUrl: 'https://cors-anywhere.herokuapp.com/https://github.com/login/oauth/access_token',
5+
homeUrl: 'http://localhost:8080/#/home'
66
};

vue.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module.exports = {
2-
publicPath: process.env.NODE_ENV === 'production' ? '/Codebadge/' : '/'
2+
publicPath: '/'
33
};

0 commit comments

Comments
 (0)