nicolas-arnaud
2 years ago
9 changed files with 66 additions and 65 deletions
@ -1,7 +0,0 @@ |
|||||
import { Module } from '@nestjs/common' |
|
||||
import { ApiController } from './api.controller' |
|
||||
|
|
||||
@Module({ |
|
||||
controllers: [ApiController] |
|
||||
}) |
|
||||
export class ApiModule {} |
|
@ -1,14 +1,14 @@ |
|||||
import { Controller, Get, Redirect, Req, UseGuards } from '@nestjs/common' |
import { Controller, Get, Redirect, Req, UseGuards } from '@nestjs/common' |
||||
import { User } from 'src/auth/42.decorator' |
|
||||
import { AuthenticatedGuard } from 'src/auth/42-auth.guard' |
|
||||
import { Profile } from 'passport-42' |
|
||||
import { Request } from 'express' |
import { Request } from 'express' |
||||
|
import { Profile } from 'passport-42' |
||||
|
import { FtUser } from './auth/42.decorator' |
||||
|
import { AuthenticatedGuard } from './auth/42-auth.guard' |
||||
|
|
||||
@Controller() |
@Controller() |
||||
export class ApiController { |
export class AppController { |
||||
@Get('profile') |
@Get('profile') |
||||
@UseGuards(AuthenticatedGuard) |
@UseGuards(AuthenticatedGuard) |
||||
profile (@User() user: Profile) { |
profile (@FtUser() user: Profile) { |
||||
return { user } |
return { user } |
||||
} |
} |
||||
|
|
@ -1,8 +0,0 @@ |
|||||
import { type Request } from 'express' |
|
||||
import type User from 'src/users/user.entity' |
|
||||
|
|
||||
interface RequestWithUser extends Request { |
|
||||
user: User |
|
||||
} |
|
||||
|
|
||||
export default RequestWithUser |
|
Loading…
Reference in new issue