Skip to content
This repository was archived by the owner on Jun 30, 2021. It is now read-only.

Improve intel 2 to implement 1 #74

Merged
merged 3 commits into from
May 27, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -173,8 +173,7 @@ export class Intel implements IIntel {
githubClient = new GithubClient();
}

let profileData = (await githubClient.endpoint.send(
"query",
let profileData = (await githubClient.gql.sendQuery(
github.queries.profile(),
{
username: source.user,
@@ -184,8 +183,7 @@ export class Intel implements IIntel {
}
)) as IDataUser;

let calendarData = (await githubClient.endpoint.send(
"query",
let calendarData = (await githubClient.gql.sendQuery(
github.queries.calendar(profileData.data.user as IProfile),
{
username: source.user,
6 changes: 3 additions & 3 deletions src/reducer/database/osm/statements/repository.ts
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ CREATE TABLE IF NOT EXISTS repository
avatarUrl VARCHAR(2048) NOT NULL,
url VARCHAR(2048) NOT NULL,
name VARCHAR(80) NOT NULL,
ownerid INT NULL REFERENCES member (id),
ownerId INT NULL REFERENCES member (id),
UNIQUE(url),
PRIMARY KEY (id)
);
@@ -19,7 +19,7 @@ INSERT INTO repository
(avatarUrl,
url,
name,
ownerid)
ownerId)
VALUES (?,
?,
?,
@@ -45,7 +45,7 @@ SELECT r.id AS id,
m.username AS owner
FROM repository r
INNER JOIN member m
ON r.ownerid = m.id
ON r.ownerId = m.id
`;
//#endregion

23 changes: 14 additions & 9 deletions src/utils/oauth/GithubProvider.ts
Original file line number Diff line number Diff line change
@@ -19,13 +19,13 @@ let details = providerConfig.details.deploy;
const GithubProvider: IProvider<boolean> = {
/**
* Builds authorization url
*
*
* @returns {string} The builded authorization url.
* @description Build the authorization url for the OAuth-Request, the values are obtained from the config file.
*/
buildAuthorizeUrl(): string {
let href = window.location.href.toString();

if (href.includes(Config.devUrl)) {
details = providerConfig.details.dev;
}
@@ -86,8 +86,13 @@ const GithubProvider: IProvider<boolean> = {
state = stateMatch[1];
}

const AuthorizeUrl = `${Config.proxyUrl}${providerConfig.urls.accessTokenUrl}${code}
&client_secret=${details.clientSecret}&client_id=${details.clientId}&redirect_uri=${details.redirectUrl}&state=${state}`;
const AuthorizeUrl =
`${Config.proxyUrl}` +
`${providerConfig.urls.accessTokenUrl}${code}` +
`&client_secret=${details.clientSecret}` +
`&client_id=${details.clientId}` +
`&redirect_uri=${details.redirectUrl}` +
`&state=${state}`;

/* POST request to get the access token from GitHub */
await fetch(AuthorizeUrl, {
@@ -97,9 +102,9 @@ const GithubProvider: IProvider<boolean> = {
"Access-Control-Allow-Methods": "POST",
"Access-Control-Allow-Origin": "*",
"Content-Type": "application/json",
Vary: "Origin"
Vary: "Origin",
},
method: "POST"
method: "POST",
})
.then(async (res) => await res.json())
.then(async (res) => {
@@ -108,8 +113,8 @@ const GithubProvider: IProvider<boolean> = {
/* GET request to get the user used for OAuth */
await fetch(`${providerConfig.urls.usernameUrl}`, {
headers: {
authorization: "Token " + accessToken
}
authorization: "Token " + accessToken,
},
})
.then(async (res) => await res.json())
.then((res) => {
@@ -120,7 +125,7 @@ const GithubProvider: IProvider<boolean> = {
});

return data;
}
},
};
//#endregion