From 8a9264b9deaff21f5355c59e28d356f099fc4a15 Mon Sep 17 00:00:00 2001 From: garrettmills Date: Thu, 28 Apr 2022 14:58:06 -0500 Subject: [PATCH] Simplify /oauth2/issue logic --- package.json | 2 +- src/auth/server/OAuth2Server.ts | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index ba0a8a5..cdc493c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@extollo/lib", - "version": "0.9.37", + "version": "0.9.38", "description": "The framework library that lifts up your code.", "main": "lib/index.js", "types": "lib/index.d.ts", diff --git a/src/auth/server/OAuth2Server.ts b/src/auth/server/OAuth2Server.ts index 41f8d17..1056108 100644 --- a/src/auth/server/OAuth2Server.ts +++ b/src/auth/server/OAuth2Server.ts @@ -13,7 +13,7 @@ import { TokenRepository, } from './types' import {HTTPError} from '../../http/HTTPError' -import {Awaitable, HTTPStatus, Maybe, right} from '../../util' +import {HTTPStatus, Maybe} from '../../util' import {view} from '../../http/response/ViewResponseFactory' import {SecurityContext} from '../context/SecurityContext' import {redirect} from '../../http/response/RedirectResponseFactory' @@ -50,14 +50,13 @@ export class OAuth2Server extends Controller { Route.post('/oauth2/token') .alias('@oauth2:token') - .parameterMiddleware(async req => - right(await req.make(OAuth2Server).getClientFromRequest(req))) .passingRequest() .calls(OAuth2Server, x => x.issue) } - issue(request: Request, client: OAuth2Client): Awaitable { + async issue(request: Request): Promise { const grant = request.safe('grant_type').in(grantTypes) + const client = await this.getClientFromRequest(request) if ( grant === GrantType.Client ) { return this.issueFromClient(request, client)