refactor(Oauth-sessions): refactor OAuth-Access-Token to OAuth-sessions
This commit is contained in:
parent
5aac046356
commit
b0406b3a4c
|
|
@ -3,7 +3,7 @@
|
|||
"paths": {
|
||||
"/": {
|
||||
"get": {
|
||||
"operationId": "AppController_getHello",
|
||||
"operationId": "ShiftsValidationController_getSummary",
|
||||
"parameters": [],
|
||||
"responses": {
|
||||
"200": {
|
||||
|
|
@ -11,7 +11,7 @@
|
|||
}
|
||||
},
|
||||
"tags": [
|
||||
"App"
|
||||
"ShiftsValidation"
|
||||
]
|
||||
}
|
||||
},
|
||||
|
|
@ -933,6 +933,20 @@
|
|||
]
|
||||
}
|
||||
},
|
||||
"/export.csv": {
|
||||
"get": {
|
||||
"operationId": "ShiftsValidationController_exportCsv",
|
||||
"parameters": [],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": ""
|
||||
}
|
||||
},
|
||||
"tags": [
|
||||
"ShiftsValidation"
|
||||
]
|
||||
}
|
||||
},
|
||||
"/leave-requests": {
|
||||
"post": {
|
||||
"operationId": "LeaveRequestController_create",
|
||||
|
|
@ -1468,27 +1482,27 @@
|
|||
]
|
||||
}
|
||||
},
|
||||
"/oauth-access-tokens": {
|
||||
"/oauth-sessions": {
|
||||
"post": {
|
||||
"operationId": "OauthAccessTokensController_create",
|
||||
"operationId": "OauthSessionsController_create",
|
||||
"parameters": [],
|
||||
"requestBody": {
|
||||
"required": true,
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/CreateOauthAccessTokenDto"
|
||||
"$ref": "#/components/schemas/CreateOauthSessionDto"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"responses": {
|
||||
"201": {
|
||||
"description": "OAuth access token created",
|
||||
"description": "OAuth session created",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/OAuthAccessTokenEntity"
|
||||
"$ref": "#/components/schemas/OAuthSessionEntity"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1499,49 +1513,49 @@
|
|||
},
|
||||
"security": [
|
||||
{
|
||||
"access-token": []
|
||||
"sessions": []
|
||||
}
|
||||
],
|
||||
"summary": "Create OAuth access token",
|
||||
"summary": "Create OAuth session",
|
||||
"tags": [
|
||||
"OAuth Access Tokens"
|
||||
"OAuth Sessions"
|
||||
]
|
||||
},
|
||||
"get": {
|
||||
"operationId": "OauthAccessTokensController_findAll",
|
||||
"operationId": "OauthSessionsController_findAll",
|
||||
"parameters": [],
|
||||
"responses": {
|
||||
"201": {
|
||||
"description": "List of OAuth access token found",
|
||||
"description": "List of OAuth session found",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/OAuthAccessTokenEntity"
|
||||
"$ref": "#/components/schemas/OAuthSessionEntity"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "List of OAuth access token not found"
|
||||
"description": "List of OAuth session not found"
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"access-token": []
|
||||
"sessions": []
|
||||
}
|
||||
],
|
||||
"summary": "Find all OAuth access token",
|
||||
"summary": "Find all OAuth session",
|
||||
"tags": [
|
||||
"OAuth Access Tokens"
|
||||
"OAuth Sessions"
|
||||
]
|
||||
}
|
||||
},
|
||||
"/oauth-access-tokens/{id}": {
|
||||
"/oauth-sessions/{id}": {
|
||||
"get": {
|
||||
"operationId": "OauthAccessTokensController_findOne",
|
||||
"operationId": "OauthSessionsController_findOne",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "id",
|
||||
|
|
@ -1554,31 +1568,31 @@
|
|||
],
|
||||
"responses": {
|
||||
"201": {
|
||||
"description": "OAuth access token found",
|
||||
"description": "OAuth session found",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/OAuthAccessTokenEntity"
|
||||
"$ref": "#/components/schemas/OAuthSessionEntity"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "OAuth access token not found"
|
||||
"description": "OAuth session not found"
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"access-token": []
|
||||
"sessions": []
|
||||
}
|
||||
],
|
||||
"summary": "Find OAuth access token",
|
||||
"summary": "Find OAuth session",
|
||||
"tags": [
|
||||
"OAuth Access Tokens"
|
||||
"OAuth Sessions"
|
||||
]
|
||||
},
|
||||
"patch": {
|
||||
"operationId": "OauthAccessTokensController_update",
|
||||
"operationId": "OauthSessionsController_update",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "id",
|
||||
|
|
@ -1594,38 +1608,38 @@
|
|||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/UpdateOauthAccessTokenDto"
|
||||
"$ref": "#/components/schemas/UpdateOauthSessionDto"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"responses": {
|
||||
"201": {
|
||||
"description": "OAuth access token updated",
|
||||
"description": "OAuth session updated",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/OAuthAccessTokenEntity"
|
||||
"$ref": "#/components/schemas/OAuthSessionEntity"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "OAuth access token not found"
|
||||
"description": "OAuth session not found"
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"access-token": []
|
||||
"sessions": []
|
||||
}
|
||||
],
|
||||
"summary": "Update OAuth access token",
|
||||
"summary": "Update OAuth session",
|
||||
"tags": [
|
||||
"OAuth Access Tokens"
|
||||
"OAuth Sessions"
|
||||
]
|
||||
},
|
||||
"delete": {
|
||||
"operationId": "OauthAccessTokensController_remove",
|
||||
"operationId": "OauthSessionsController_remove",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "id",
|
||||
|
|
@ -1638,27 +1652,27 @@
|
|||
],
|
||||
"responses": {
|
||||
"201": {
|
||||
"description": "OAuth access token deleted",
|
||||
"description": "OAuth session deleted",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/OAuthAccessTokenEntity"
|
||||
"$ref": "#/components/schemas/OAuthSessionEntity"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "OAuth access token not found"
|
||||
"description": "OAuth session not found"
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"access-token": []
|
||||
"sessions": []
|
||||
}
|
||||
],
|
||||
"summary": "Delete OAuth access token",
|
||||
"summary": "Delete OAuth session",
|
||||
"tags": [
|
||||
"OAuth Access Tokens"
|
||||
"OAuth Sessions"
|
||||
]
|
||||
}
|
||||
},
|
||||
|
|
@ -2453,7 +2467,7 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"CreateOauthAccessTokenDto": {
|
||||
"CreateOauthSessionDto": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"user_id": {
|
||||
|
|
@ -2505,7 +2519,7 @@
|
|||
"access_token_expiry"
|
||||
]
|
||||
},
|
||||
"OAuthAccessTokenEntity": {
|
||||
"OAuthSessionEntity": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
|
|
@ -2586,7 +2600,7 @@
|
|||
"created_at"
|
||||
]
|
||||
},
|
||||
"UpdateOauthAccessTokenDto": {
|
||||
"UpdateOauthSessionDto": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"user_id": {
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ import { PrismaModule } from './prisma/prisma.module';
|
|||
import { HealthModule } from './health/health.module';
|
||||
import { HealthController } from './health/health.controller';
|
||||
import { UsersModule } from './modules/users-management/users.module';
|
||||
import { OauthAccessTokensModule } from './modules/oauth-access-tokens/oauth-access-tokens.module';
|
||||
import { CustomersModule } from './modules/customers/customers.module';
|
||||
import { EmployeesModule } from './modules/employees/employees.module';
|
||||
import { LeaveRequestsModule } from './modules/leave-requests/leave-requests.module';
|
||||
|
|
@ -20,6 +19,7 @@ import { BankCodesModule } from './modules/bank-codes/bank-codes.module';
|
|||
import { OvertimeService } from './modules/business-logics/services/overtime.service';
|
||||
import { BusinessLogicsModule } from './modules/business-logics/business-logics.module';
|
||||
import { ShiftsValidationModule } from './modules/shifts/validation/shifts-validation.module';
|
||||
import { OauthSessionsModule } from './modules/oauth-sessions/oauth-sessions.module';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
|
|
@ -33,7 +33,7 @@ import { ShiftsValidationModule } from './modules/shifts/validation/shifts-valid
|
|||
ExpensesModule,
|
||||
HealthModule,
|
||||
LeaveRequestsModule,
|
||||
OauthAccessTokensModule,
|
||||
OauthSessionsModule,
|
||||
PayperiodsModule,
|
||||
PrismaModule,
|
||||
ShiftsModule,
|
||||
|
|
|
|||
|
|
@ -1,63 +0,0 @@
|
|||
import { Body, Controller, Delete, Get, Param, Patch, Post, UseGuards } from '@nestjs/common';
|
||||
import { OauthAccessTokensService } from '../services/oauth-access-tokens.service';
|
||||
import { CreateOauthAccessTokenDto } from '../dtos/create-oauth-access-token.dto';
|
||||
import { OAuthAccessTokens } from '@prisma/client';
|
||||
import { UpdateOauthAccessTokenDto } from '../dtos/update-oauth-access-token.dto';
|
||||
import { RolesAllowed } from "src/common/decorators/roles.decorators";
|
||||
import { Roles as RoleEnum } from '.prisma/client';
|
||||
import { ApiBearerAuth, ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';
|
||||
import { JwtAuthGuard } from 'src/modules/authentication/guards/jwt-auth.guard';
|
||||
import { OAuthAccessTokenEntity } from '../dtos/swagger-entities/oauth-access-token.entity';
|
||||
|
||||
@ApiTags('OAuth Access Tokens')
|
||||
@ApiBearerAuth('access-token')
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@Controller('oauth-access-tokens')
|
||||
export class OauthAccessTokensController {
|
||||
constructor(private readonly oauthAccessTokensService: OauthAccessTokensService){}
|
||||
|
||||
@Post()
|
||||
@RolesAllowed(RoleEnum.ADMIN)
|
||||
@ApiOperation({summary: 'Create OAuth access token' })
|
||||
@ApiResponse({ status: 201, description: 'OAuth access token created', type: OAuthAccessTokenEntity })
|
||||
@ApiResponse({ status: 400, description: 'Incomplete task or invalid data' })
|
||||
create(@Body()dto: CreateOauthAccessTokenDto): Promise<OAuthAccessTokens> {
|
||||
return this.oauthAccessTokensService.create(dto);
|
||||
}
|
||||
|
||||
@Get()
|
||||
@RolesAllowed(RoleEnum.ADMIN)
|
||||
@ApiOperation({summary: 'Find all OAuth access token' })
|
||||
@ApiResponse({ status: 201, description: 'List of OAuth access token found', type: OAuthAccessTokenEntity, isArray: true })
|
||||
@ApiResponse({ status: 400, description: 'List of OAuth access token not found' })
|
||||
findAll(): Promise<OAuthAccessTokens[]> {
|
||||
return this.oauthAccessTokensService.findAll();
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
@RolesAllowed(RoleEnum.ADMIN)
|
||||
@ApiOperation({summary: 'Find OAuth access token' })
|
||||
@ApiResponse({ status: 201, description: 'OAuth access token found', type: OAuthAccessTokenEntity })
|
||||
@ApiResponse({ status: 400, description: 'OAuth access token not found' })
|
||||
findOne(@Param('id') id: string): Promise<OAuthAccessTokens> {
|
||||
return this.oauthAccessTokensService.findOne(id);
|
||||
}
|
||||
|
||||
@Patch(':id')
|
||||
@RolesAllowed(RoleEnum.ADMIN)
|
||||
@ApiOperation({summary: 'Update OAuth access token' })
|
||||
@ApiResponse({ status: 201, description: 'OAuth access token updated', type: OAuthAccessTokenEntity })
|
||||
@ApiResponse({ status: 400, description: 'OAuth access token not found' })
|
||||
update(@Param('id') id: string, @Body() dto: UpdateOauthAccessTokenDto): Promise<OAuthAccessTokens> {
|
||||
return this.oauthAccessTokensService.update(id,dto);
|
||||
}
|
||||
|
||||
@Delete(':id')
|
||||
@RolesAllowed(RoleEnum.ADMIN)
|
||||
@ApiOperation({summary: 'Delete OAuth access token' })
|
||||
@ApiResponse({ status: 201, description: 'OAuth access token deleted', type: OAuthAccessTokenEntity })
|
||||
@ApiResponse({ status: 400, description: 'OAuth access token not found' })
|
||||
remove(@Param('id') id: string): Promise<OAuthAccessTokens> {
|
||||
return this.oauthAccessTokensService.remove(id);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
import { PartialType } from "@nestjs/swagger";
|
||||
import { CreateOauthAccessTokenDto } from "./create-oauth-access-token.dto";
|
||||
|
||||
export class UpdateOauthAccessTokenDto extends PartialType(CreateOauthAccessTokenDto) {}
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
import { Module } from '@nestjs/common';
|
||||
import { OauthAccessTokensController } from './controllers/oauth-access-tokens.controller';
|
||||
import { OauthAccessTokensService } from './services/oauth-access-tokens.service';
|
||||
import { PrismaService } from 'src/prisma/prisma.service';
|
||||
|
||||
@Module({
|
||||
controllers: [OauthAccessTokensController],
|
||||
providers: [OauthAccessTokensService, PrismaService]
|
||||
})
|
||||
export class OauthAccessTokensModule {}
|
||||
|
|
@ -0,0 +1,63 @@
|
|||
import { Body, Controller, Delete, Get, Param, Patch, Post, UseGuards } from '@nestjs/common';
|
||||
import { OAuthSessions } from '@prisma/client';
|
||||
import { RolesAllowed } from "src/common/decorators/roles.decorators";
|
||||
import { Roles as RoleEnum } from '.prisma/client';
|
||||
import { ApiBearerAuth, ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';
|
||||
import { JwtAuthGuard } from 'src/modules/authentication/guards/jwt-auth.guard';
|
||||
import { CreateOauthSessionDto } from '../dtos/create-oauth-sessions.dto';
|
||||
import { OauthSessionsService } from '../services/oauth-sessions.service';
|
||||
import { OAuthSessionEntity } from '../dtos/swagger-entities/oauth-sessions.entity';
|
||||
import { UpdateOauthSessionDto } from '../dtos/update-oauth-sessions.dto';
|
||||
|
||||
@ApiTags('OAuth Sessions')
|
||||
@ApiBearerAuth('sessions')
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@Controller('oauth-sessions')
|
||||
export class OauthSessionsController {
|
||||
constructor(private readonly oauthSessionsService: OauthSessionsService){}
|
||||
|
||||
@Post()
|
||||
@RolesAllowed(RoleEnum.ADMIN)
|
||||
@ApiOperation({summary: 'Create OAuth session' })
|
||||
@ApiResponse({ status: 201, description: 'OAuth session created', type: OAuthSessionEntity })
|
||||
@ApiResponse({ status: 400, description: 'Incomplete task or invalid data' })
|
||||
create(@Body()dto: CreateOauthSessionDto): Promise<OAuthSessions> {
|
||||
return this.oauthSessionsService.create(dto);
|
||||
}
|
||||
|
||||
@Get()
|
||||
@RolesAllowed(RoleEnum.ADMIN)
|
||||
@ApiOperation({summary: 'Find all OAuth session' })
|
||||
@ApiResponse({ status: 201, description: 'List of OAuth session found', type: OAuthSessionEntity, isArray: true })
|
||||
@ApiResponse({ status: 400, description: 'List of OAuth session not found' })
|
||||
findAll(): Promise<OAuthSessions[]> {
|
||||
return this.oauthSessionsService.findAll();
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
@RolesAllowed(RoleEnum.ADMIN)
|
||||
@ApiOperation({summary: 'Find OAuth session' })
|
||||
@ApiResponse({ status: 201, description: 'OAuth session found', type: OAuthSessionEntity })
|
||||
@ApiResponse({ status: 400, description: 'OAuth session not found' })
|
||||
findOne(@Param('id') id: string): Promise<OAuthSessions> {
|
||||
return this.oauthSessionsService.findOne(id);
|
||||
}
|
||||
|
||||
@Patch(':id')
|
||||
@RolesAllowed(RoleEnum.ADMIN)
|
||||
@ApiOperation({summary: 'Update OAuth session' })
|
||||
@ApiResponse({ status: 201, description: 'OAuth session updated', type: OAuthSessionEntity })
|
||||
@ApiResponse({ status: 400, description: 'OAuth session not found' })
|
||||
update(@Param('id') id: string, @Body() dto: UpdateOauthSessionDto): Promise<OAuthSessions> {
|
||||
return this.oauthSessionsService.update(id,dto);
|
||||
}
|
||||
|
||||
@Delete(':id')
|
||||
@RolesAllowed(RoleEnum.ADMIN)
|
||||
@ApiOperation({summary: 'Delete OAuth session' })
|
||||
@ApiResponse({ status: 201, description: 'OAuth session deleted', type: OAuthSessionEntity })
|
||||
@ApiResponse({ status: 400, description: 'OAuth session not found' })
|
||||
remove(@Param('id') id: string): Promise<OAuthSessions> {
|
||||
return this.oauthSessionsService.remove(id);
|
||||
}
|
||||
}
|
||||
|
|
@ -2,7 +2,7 @@ import { ApiProperty } from "@nestjs/swagger";
|
|||
import { Type } from "class-transformer";
|
||||
import { IsArray, IsDate, IsOptional, IsString, IsUUID } from "class-validator";
|
||||
|
||||
export class CreateOauthAccessTokenDto {
|
||||
export class CreateOauthSessionDto {
|
||||
|
||||
@ApiProperty({
|
||||
example: 'S7A2U8R7O6N6',
|
||||
|
|
@ -18,6 +18,9 @@ export class CreateOauthAccessTokenDto {
|
|||
@IsString()
|
||||
application: string;
|
||||
|
||||
@IsString()
|
||||
sid: string;
|
||||
|
||||
@ApiProperty({
|
||||
example: 'L5O6R4D3/O6F3#T8H4E3&R6I4N6G4S7 ...',
|
||||
description: 'Access token',
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
import { ApiProperty } from '@nestjs/swagger';
|
||||
|
||||
export class OAuthAccessTokenEntity {
|
||||
export class OAuthSessionEntity {
|
||||
@ApiProperty({
|
||||
example: 'cklwi0vb70000z2z20q6f19qk',
|
||||
description: 'Unique ID of an OAuth token (auto-generated)',
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
import { PartialType } from "@nestjs/swagger";
|
||||
import { CreateOauthSessionDto } from "./create-oauth-sessions.dto";
|
||||
|
||||
export class UpdateOauthSessionDto extends PartialType(CreateOauthSessionDto) {}
|
||||
10
src/modules/oauth-sessions/oauth-sessions.module.ts
Normal file
10
src/modules/oauth-sessions/oauth-sessions.module.ts
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
import { Module } from '@nestjs/common';
|
||||
import { PrismaService } from 'src/prisma/prisma.service';
|
||||
import { OauthSessionsController } from './controllers/oauth-sessions.controller';
|
||||
import { OauthSessionsService } from './services/oauth-sessions.service';
|
||||
|
||||
@Module({
|
||||
controllers: [OauthSessionsController],
|
||||
providers: [OauthSessionsService, PrismaService]
|
||||
})
|
||||
export class OauthSessionsModule {}
|
||||
|
|
@ -1,30 +1,32 @@
|
|||
import { Injectable, NotFoundException } from '@nestjs/common';
|
||||
import { PrismaService } from 'src/prisma/prisma.service';
|
||||
import { CreateOauthAccessTokenDto } from '../dtos/create-oauth-access-token.dto';
|
||||
import { OAuthAccessTokens } from '@prisma/client';
|
||||
import { UpdateOauthAccessTokenDto } from '../dtos/update-oauth-access-token.dto';
|
||||
import { CreateOauthSessionDto } from '../dtos/create-oauth-sessions.dto';
|
||||
import { OAuthSessions } from '@prisma/client';
|
||||
import { UpdateOauthSessionDto } from '../dtos/update-oauth-sessions.dto';
|
||||
|
||||
@Injectable()
|
||||
export class OauthAccessTokensService {
|
||||
export class OauthSessionsService {
|
||||
constructor(private readonly prisma: PrismaService) {}
|
||||
|
||||
async create(dto: CreateOauthAccessTokenDto): Promise<OAuthAccessTokens> {
|
||||
async create(dto: CreateOauthSessionDto): Promise<OAuthSessions> {
|
||||
const {
|
||||
user_id,
|
||||
application,
|
||||
access_token,
|
||||
refresh_token,
|
||||
sid,
|
||||
access_token_expiry,
|
||||
refresh_token_expiry,
|
||||
scopes,
|
||||
} = dto;
|
||||
|
||||
return this.prisma.oAuthAccessTokens.create({
|
||||
return this.prisma.oAuthSessions.create({
|
||||
data: {
|
||||
user_id,
|
||||
application,
|
||||
access_token,
|
||||
refresh_token,
|
||||
sid,
|
||||
access_token_expiry,
|
||||
refresh_token_expiry,
|
||||
scopes,
|
||||
|
|
@ -33,14 +35,14 @@ export class OauthAccessTokensService {
|
|||
});
|
||||
}
|
||||
|
||||
findAll(): Promise<OAuthAccessTokens[]> {
|
||||
return this.prisma.oAuthAccessTokens.findMany({
|
||||
findAll(): Promise<OAuthSessions[]> {
|
||||
return this.prisma.oAuthSessions.findMany({
|
||||
include: { user: true },
|
||||
});
|
||||
}
|
||||
|
||||
async findOne(id: string): Promise<OAuthAccessTokens> {
|
||||
const token = await this.prisma.oAuthAccessTokens.findUnique({
|
||||
async findOne(id: string): Promise<OAuthSessions> {
|
||||
const token = await this.prisma.oAuthSessions.findUnique({
|
||||
where: { id },
|
||||
include: { user: true },
|
||||
});
|
||||
|
|
@ -50,7 +52,7 @@ export class OauthAccessTokensService {
|
|||
return token;
|
||||
}
|
||||
|
||||
async update(id: string, dto: UpdateOauthAccessTokenDto): Promise<OAuthAccessTokens> {
|
||||
async update(id: string, dto: UpdateOauthSessionDto): Promise<OAuthSessions> {
|
||||
await this.findOne(id);
|
||||
const {
|
||||
user_id,
|
||||
|
|
@ -62,7 +64,7 @@ export class OauthAccessTokensService {
|
|||
scopes,
|
||||
} = dto;
|
||||
|
||||
return this.prisma.oAuthAccessTokens.update({
|
||||
return this.prisma.oAuthSessions.update({
|
||||
where: { id },
|
||||
data: {
|
||||
...(user_id !== undefined && { user_id }),
|
||||
|
|
@ -77,8 +79,8 @@ export class OauthAccessTokensService {
|
|||
});
|
||||
}
|
||||
|
||||
async remove(id: string): Promise<OAuthAccessTokens> {
|
||||
async remove(id: string): Promise<OAuthSessions> {
|
||||
await this.findOne(id);
|
||||
return this.prisma.oAuthAccessTokens.delete({ where: { id }});
|
||||
return this.prisma.oAuthSessions.delete({ where: { id }});
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user