Skip to content

Commit 9cf304f

Browse files
mmachatschekpi0
authored andcommitted
fix(oauth2): correctly handle callback with hash (#394)
1 parent 1833143 commit 9cf304f

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

lib/schemes/oauth2.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { encodeQuery } from '../utilities'
1+
import { encodeQuery, parseQuery } from '../utilities'
22
import nanoid from 'nanoid'
33
const isHttps = process.server ? require('is-https') : null
44

@@ -133,7 +133,8 @@ export default class Oauth2Scheme {
133133
return
134134
}
135135

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

149150
// -- Authorization Code Grant --
150151
if (this.options.response_type === 'code' && parsedQuery.code) {
151-
let data = await this.$auth.request({
152+
const data = await this.$auth.request({
152153
method: 'post',
153154
url: this.options.access_token_endpoint,
154155
baseURL: process.server ? undefined : false,

0 commit comments

Comments
 (0)