|
@@ -16,6 +16,7 @@ import { ConfigService } from '@nestjs/config';
|
|
import { AuthService } from './auth.service';
|
|
import { AuthService } from './auth.service';
|
|
import { JwtGuard } from './guards/jwt.guard';
|
|
import { JwtGuard } from './guards/jwt.guard';
|
|
import { RadarScopeDto } from './dto/radarscope.dto';
|
|
import { RadarScopeDto } from './dto/radarscope.dto';
|
|
|
|
+import { RadarTokenDto } from './dto/radartoken.dto';
|
|
import { UserDto } from './dto/user.dto';
|
|
import { UserDto } from './dto/user.dto';
|
|
import { Request } from 'express';
|
|
import { Request } from 'express';
|
|
|
|
|
|
@@ -68,7 +69,7 @@ export class AuthController {
|
|
@ApiResponse({
|
|
@ApiResponse({
|
|
status: 200,
|
|
status: 200,
|
|
description: 'The created Bearer token to use endpoints',
|
|
description: 'The created Bearer token to use endpoints',
|
|
- type: String,
|
|
|
|
|
|
+ type: RadarTokenDto,
|
|
})
|
|
})
|
|
@ApiResponse({
|
|
@ApiResponse({
|
|
status: 404,
|
|
status: 404,
|
|
@@ -76,7 +77,7 @@ export class AuthController {
|
|
})
|
|
})
|
|
async radarScope(
|
|
async radarScope(
|
|
@Body('scopeData') scopeData: RadarScopeDto,
|
|
@Body('scopeData') scopeData: RadarScopeDto,
|
|
- ): Promise<string> {
|
|
|
|
|
|
+ ): Promise<RadarTokenDto> {
|
|
return this.authService
|
|
return this.authService
|
|
.loginRadarScope(scopeData.vatsimId, scopeData.key)
|
|
.loginRadarScope(scopeData.vatsimId, scopeData.key)
|
|
.then((token) => {
|
|
.then((token) => {
|
|
@@ -86,10 +87,23 @@ export class AuthController {
|
|
HttpStatus.NOT_FOUND,
|
|
HttpStatus.NOT_FOUND,
|
|
);
|
|
);
|
|
}
|
|
}
|
|
- return token;
|
|
|
|
|
|
+ return { token };
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @UseGuards(JwtGuard)
|
|
|
|
+ @Get('/validate')
|
|
|
|
+ @ApiResponse({
|
|
|
|
+ status: 200,
|
|
|
|
+ description: 'The created Bearer token to use endpoints',
|
|
|
|
+ })
|
|
|
|
+ @ApiResponse({
|
|
|
|
+ status: 401,
|
|
|
|
+ description: 'The sent Bearer token is invalid',
|
|
|
|
+ })
|
|
|
|
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
|
|
+ validate(): void {}
|
|
|
|
+
|
|
@UseGuards(JwtGuard)
|
|
@UseGuards(JwtGuard)
|
|
@Get('/user')
|
|
@Get('/user')
|
|
async user(@Req() request: Request): Promise<UserDto> {
|
|
async user(@Req() request: Request): Promise<UserDto> {
|