Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(oauth2): correctly handle callback with hash #394

Merged
merged 1 commit into from
Jun 24, 2019
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
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))
mmachatschek marked this conversation as resolved.
Show resolved Hide resolved
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