Skip to content

Commit

Permalink
fix: fix storage
Browse files Browse the repository at this point in the history
  • Loading branch information
cfabianski committed Apr 15, 2020
1 parent dbe9953 commit 6b0c98d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 23 deletions.
23 changes: 2 additions & 21 deletions src/auth/v3/strategy.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import { NextFunction, Response } from 'express'

import { EAuthType, TAuthenticateRequest } from './types'
import {
OAuthOnlyEndpoint,
InvalidAuthType
// MissingAuthId,
// CredentialsNotConfigured
} from './errors'
import { InvalidAuthType } from './errors'
import * as oauth1 from './strategies/oauth1'
import * as oauth2 from './strategies/oauth2'
import { TBackendRequestV4 } from '../../types'
Expand All @@ -22,10 +17,6 @@ export const isOAuthType = (authType: EAuthType) => [EAuthType.OAuth1, EAuthType
export const authenticate = (req: TAuthenticateRequest, res: Response, next: NextFunction) => {
const { authType } = req.integrationConfig

if (!isOAuthType(authType)) {
throw new OAuthOnlyEndpoint(authType)
}

strategies[authType].authenticate(req, res, next)
}

Expand All @@ -41,14 +32,6 @@ export const fetchAuthDetails = asyncMiddleware(async (req: TBackendRequestV4, _

const strategy = strategies[authType]

// if (isOAuthType(authType)) {
// if (!authId) {
// throw new MissingAuthId(buid)
// }
// } else if (!setupId) {
// throw new CredentialsNotConfigured(buid)
// }

const params = {
buid,
authId,
Expand All @@ -59,11 +42,9 @@ export const fetchAuthDetails = asyncMiddleware(async (req: TBackendRequestV4, _
setupIdFromRequest: !!req.query.setupId
}

// console.log(params)
// console.log(integrationConfig)
req.auth = await strategy.fetchAuthDetails(params, integrationConfig)

console.log('Auth', req.auth)
console.log('[fetchAuthDetails] Auth', req.auth)

next()
})
1 change: 1 addition & 0 deletions src/auth/v3/success.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export const authSuccess = asyncMiddleware(async (req: AuthSuccessRequest, res:
const params = {
buid,
authId,
setupId,
userAttributes
}

Expand Down
5 changes: 3 additions & 2 deletions src/clients/integrations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,11 @@ export interface IAuthResult {
export const updateAuth = async ({
buid,
authId,
setupId,
userAttributes,
store
}: IAuthParams & { userAttributes: TAuthUserAttributes } & { store: any }) => {
await store('authentications').insert({ buid, auth_id: authId, user_attributes: userAttributes })
}: IAuthParams & { userAttributes: TAuthUserAttributes } & { store: any; setupId: string }) => {
await store('authentications').insert({ buid, auth_id: authId, setup_id: setupId, user_attributes: userAttributes })
}

export const getAuth = async <IAuthResult>({ buid, authId, store }: IAuthParams & { store: any }) => {
Expand Down

0 comments on commit 6b0c98d

Please sign in to comment.