Skip to content

Commit

Permalink
fix(oauth2): correctly handle callback with hash (#394)
Browse files Browse the repository at this point in the history
  • Loading branch information
mmachatschek authored and pi0 committed Jun 24, 2019
1 parent 1833143 commit 9cf304f
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/schemes/oauth2.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { encodeQuery } from '../utilities'
import { encodeQuery, parseQuery } from '../utilities'
import nanoid from 'nanoid'
const isHttps = process.server ? require('is-https') : null

Expand Down Expand Up @@ -133,7 +133,8 @@ export default class Oauth2Scheme {
return
}

const parsedQuery = Object.assign({}, this.$auth.ctx.route.query, this.$auth.ctx.route.hash)
const hash = parseQuery(this.$auth.ctx.route.hash.substr(1))
const parsedQuery = Object.assign({}, this.$auth.ctx.route.query, hash)
// accessToken/idToken
let token = parsedQuery[this.options.token_key || 'access_token']
// refresh token
Expand All @@ -148,7 +149,7 @@ export default class Oauth2Scheme {

// -- Authorization Code Grant --
if (this.options.response_type === 'code' && parsedQuery.code) {
let data = await this.$auth.request({
const data = await this.$auth.request({
method: 'post',
url: this.options.access_token_endpoint,
baseURL: process.server ? undefined : false,
Expand Down

0 comments on commit 9cf304f

Please sign in to comment.