nestjs_auth ini...
This commit is contained in:
parent
881d4dee74
commit
4cd14dbb6d
@ -3,13 +3,13 @@
|
||||
|
||||
import { Module } from '@nestjs/common'
|
||||
import { PassportModule } from '@nestjs/passport'
|
||||
import { UsersModule } from 'src/user/user.module'
|
||||
import { AuthService } from './auth.service'
|
||||
import { JwtModule } from '@nestjs/jwt'
|
||||
import { jwtConstants } from './guards/constants'
|
||||
import { AuthController } from './auth.controller'
|
||||
import { LocalStrategy } from './guards/local.strategy'
|
||||
import { JwtStrategy } from './guards/jwt.strategy'
|
||||
import { UsersModule } from '../user/user.module'
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
@ -20,8 +20,8 @@ import { JwtStrategy } from './guards/jwt.strategy'
|
||||
signOptions: { expiresIn: jwtConstants.expiresIn }
|
||||
})
|
||||
],
|
||||
controllers: [AuthController],
|
||||
providers: [AuthService, LocalStrategy, JwtStrategy],
|
||||
exports: [AuthService],
|
||||
controllers: [AuthController]
|
||||
exports: [AuthService]
|
||||
})
|
||||
export class AuthModule {}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { Injectable } from '@nestjs/common'
|
||||
import { UserService } from 'src/user/user.service'
|
||||
import { JwtService } from '@nestjs/jwt'
|
||||
import { UserService } from '../user/user.service'
|
||||
|
||||
@Injectable()
|
||||
export class AuthService {
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { Strategy } from 'passport-local'
|
||||
import { PassportStrategy } from '@nestjs/passport'
|
||||
import { Injectable, UnauthorizedException } from '@nestjs/common'
|
||||
import { AuthService } from 'src/auth/auth.service'
|
||||
import { AuthService } from '../auth.service'
|
||||
import { env } from 'process'
|
||||
|
||||
@Injectable()
|
||||
|
||||
@ -12,10 +12,10 @@ import {
|
||||
import { User } from '@prisma/client'
|
||||
import { UserDTO } from './dtos/user.dto'
|
||||
import { UserService } from './user.service'
|
||||
import { HasRoles } from 'src/auth/decorators/has-roles.decorator'
|
||||
import { JwtAuthGuard } from 'src/auth/guards/jwt.authguard'
|
||||
import { Role } from 'src/auth/guards/role.enum'
|
||||
import { RolesGuard } from 'src/auth/guards/roles.guard'
|
||||
import { HasRoles } from '../auth/decorators/has-roles.decorator'
|
||||
import { JwtAuthGuard } from '../auth/guards/jwt.authguard'
|
||||
import { Role } from '../auth/guards/role.enum'
|
||||
import { RolesGuard } from '../auth/guards/roles.guard'
|
||||
|
||||
@Controller('user')
|
||||
export class UserController {
|
||||
@ -130,7 +130,7 @@ export class UserController {
|
||||
@UseGuards(JwtAuthGuard, RolesGuard)
|
||||
@Get(':id')
|
||||
async fetchOne(@Param('id') id: number): Promise<User | undefined> {
|
||||
return this.userService.fetchOne(id)
|
||||
return await this.userService.fetchOne({ id: Number(id) })
|
||||
}
|
||||
|
||||
// @HasRoles(Role.USER)
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { Module } from '@nestjs/common'
|
||||
import { PrismaService } from 'src/prisma.service'
|
||||
import { PrismaService } from '../prisma.service'
|
||||
import { UserService } from './user.service'
|
||||
import { UserController } from './user.controller'
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { Injectable } from '@nestjs/common'
|
||||
import { Prisma, User } from '@prisma/client'
|
||||
import { PrismaService } from 'src/prisma.service'
|
||||
import { PrismaService } from '../prisma.service'
|
||||
|
||||
@Injectable()
|
||||
export class UserService {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user