add launcher oauth exchange api

This commit is contained in:
2026-07-06 11:46:31 +09:00
parent 7e7a10f8a2
commit 8461adfb3d
3 changed files with 38 additions and 2 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "atnmy-stdo-v2-be", "name": "atnmy-stdo-v2-be",
"version": "1.0.1", "version": "1.0.2",
"description": "", "description": "",
"author": "", "author": "",
"private": true, "private": true,
+18 -1
View File
@@ -1,4 +1,4 @@
import { Body, Controller, Delete, Get, Post, Put, Req, Res } from '@nestjs/common'; import { BadRequestException, Body, Controller, Delete, Get, Post, Put, Req, Res } from '@nestjs/common';
import type { Request, Response } from 'express'; import type { Request, Response } from 'express';
import { AuthService } from './auth.service'; import { AuthService } from './auth.service';
@@ -32,6 +32,23 @@ export class AuthController {
return this.authService.refresh(request.headers.cookie, response); return this.authService.refresh(request.headers.cookie, response);
} }
@Post('oauth/exchange')
exchangeOAuthLoginToken(
@Body() body: { loginToken?: string },
@Req() request: Request,
@Res({ passthrough: true }) response: Response,
) {
if (!body.loginToken) {
throw new BadRequestException('loginToken is required');
}
return this.authService.exchangeOAuthLoginToken(
body.loginToken,
request.headers.cookie,
response,
);
}
@Post('logout') @Post('logout')
logout( logout(
@Req() request: Request, @Req() request: Request,
+19
View File
@@ -63,6 +63,25 @@ export class AuthService {
return this.frontendTokenResponse(authResponse); return this.frontendTokenResponse(authResponse);
} }
async exchangeOAuthLoginToken(
loginToken: string,
cookieHeader: string | undefined,
response: Response,
) {
const authResponse = await this.request<AuthTokenResponse>(
'/auth/oauth/exchange',
{
method: 'POST',
body: { loginToken },
cookieHeader,
response,
unauthorizedMessage: 'Invalid Google login session',
},
);
return this.frontendTokenResponse(authResponse);
}
async logout( async logout(
cookieHeader: string | undefined, cookieHeader: string | undefined,
response: Response, response: Response,