Skip to content

Commit

Permalink
Fix /start path of VTEX ID API.
Browse files Browse the repository at this point in the history
  • Loading branch information
Bruno Dias committed Sep 4, 2018
1 parent 8ef7c43 commit 900c7f6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Fixed
- Fix `/start` path of VTEX ID API.
### Changed
- Refact the auth mutations to make `POST` instead `GET` requests in API.

## [2.25.3] - 2018-08-31
### Added
Expand Down
8 changes: 4 additions & 4 deletions node/resolvers/auth/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@ import { withAuthToken, headers } from '../headers'
import ResolverError from '../../errors/resolverError'


const makeRequest = async (ctx, url, vtexIdVersion='store-graphql') => {
const makeRequest = async (ctx, url, method='POST', vtexIdVersion='store-graphql') => {
const configRequest = async (ctx, url, vtexIdVersion) => ({
headers: withAuthToken({...headers.profile, 'vtex-ui-id-version': vtexIdVersion})(ctx),
enableCookies: true,
method: 'GET',
method,
url,
})
return await http.request(await configRequest(ctx, url, vtexIdVersion))
}

const getSessionToken = async (ioContext, redirectUrl?) => {
const { data, status } = await makeRequest(ioContext, paths.sessionToken(ioContext.account, ioContext.account, redirectUrl))
const { data, status } = await makeRequest(ioContext, paths.sessionToken(ioContext.account, ioContext.account, redirectUrl), 'GET')
if (!data.authenticationToken) {
throw new ResolverError(`ERROR ${data}`, status)
}
Expand Down Expand Up @@ -58,7 +58,7 @@ export const queries = {
showClassicAuthentication,
showAccessKeyAuthentication
} } = await makeRequest(ioContext,
paths.sessionToken(ioContext.account, ioContext.account)
paths.sessionToken(ioContext.account, ioContext.account), 'GET'
)
return {
providers: oauthProviders,
Expand Down
3 changes: 2 additions & 1 deletion node/resolvers/paths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ const paths = {
/** VTEX ID API */
vtexId: `http://vtexid.vtex.com.br/api/vtexid/pub`,
identity: (account, { token }) => `${paths.vtexId}/authenticated/user?authToken=${encodeURIComponent(token)}`,
sessionToken: (scope, account, redirect = '/') => `${paths.vtexId}/authentication/start?appStart=true&scope=${scope}&accountName=${account}${redirect && `&callbackUrl=${redirect}/`}`,
sessionToken: (scope, account, redirect = '/', returnUrl = '/'
) => `${paths.vtexId}/authentication/start?appStart=true&scope=${scope}&accountName=${account}${redirect && `&callbackUrl=${redirect}`}${returnUrl && `&returnUrl=${returnUrl}`}`,
sendEmailVerification: (email, token) => `${paths.vtexId}/authentication/accesskey/send?authenticationToken=${token}&email=${email}`,
accessKeySignIn: (token, email, code) => `${paths.vtexId}/authentication/accesskey/validate?authenticationToken=${token}&login=${email}&accesskey=${code}`,
classicSignIn: (token, email, password) => `${paths.vtexId}/authentication/classic/validate?authenticationToken=${token}&login=${email}&password=${password}`,
Expand Down

0 comments on commit 900c7f6

Please sign in to comment.