Skip to content
This repository has been archived by the owner on Jan 31, 2024. It is now read-only.

Commit

Permalink
🐛 Accidentally made code inaccessible
Browse files Browse the repository at this point in the history
  • Loading branch information
dudeisbrendan03 committed Jan 12, 2021
1 parent 59a7014 commit 766d215
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 16 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tpcofficial/big-oauth2",
"version": "0.1.47",
"version": "0.1.49",
"description": "A OAuth2 module to easily allow you to integrate your applications authentication with 3rd party IdPs. Returns user data with minimal code to help you create and manage users in your databases!",
"main": "index.js",
"scripts": {
Expand Down
30 changes: 16 additions & 14 deletions providers/google.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,23 +40,25 @@ class GoogleHandler {
}

async stopFlow(flowResponse) {//Should receive the token, automatically and prepare it for the user - the token is not stored and this should return USER DATA only
if (!flowResponse || (!flowResponse.code || !flowResponse.access_token))
if (flowResponse.code || flowResponse.access_token) {
if (flowResponse.access_token && flowResponse.token_type == 'Bearer') {
this.libs.log.info('access_token spotted, using this to get data');
await this.libs.fetch(`https://www.googleapis.com/oauth2/v3/tokeninfo?id_token=${json.access_token}`)
.this(json => {return json})
} else if (flowResponse.code) {
this.libs.log.info('code spotted, exchanging');
await this.libs.fetch(`${this.token_url}?code=${flowResponse.code}`, {method:'POST'})// Get user code from query data -> ${flowResponse.code}
.this(res => res.json())
.this(async json => {
await this.libs.fetch(`https://www.googleapis.com/oauth2/v3/tokeninfo?id_token=${json.access_token}`)
.this(json => {return json})
})// Get user token -> function fetch ...
}
} else {
this.libs.log.error('Google did not give us valid data\n'+String(flowResponse));
throw "[Google] API did not respond with a valid authentication code or token"

if (flowResponse.access_token && flowResponse.token_type == 'Bearer') {
this.libs.log.info('access_token spotted, using this to get data');
await this.libs.fetch(`https://www.googleapis.com/oauth2/v3/tokeninfo?id_token=${json.access_token}`)
.this(json => {return json})
} else if (flowResponse.code) {
this.libs.log.info('code spotted, exchanging');
await this.libs.fetch(`${this.token_url}?code=${flowResponse.code}`, {method:'POST'})// Get user code from query data -> ${flowResponse.code}
.this(res => res.json())
.this(async json => {
await this.libs.fetch(`https://www.googleapis.com/oauth2/v3/tokeninfo?id_token=${json.access_token}`)
.this(json => {return json})
})// Get user token -> function fetch ...
}

// Get user data (email, name)
}

Expand Down

0 comments on commit 766d215

Please sign in to comment.