File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -206,9 +206,10 @@ export function Role(roleName: string | string[]): MethodDecorator {
206206编写一个守卫,用于角色鉴权。
207207
208208``` typescript
209- import { IMiddleware , Guard , IGuard , getPropertyMetadata } from ' @midwayjs/core' ;
209+ // src/guard/auth.guard.ts
210+ import { Guard , IGuard , getPropertyMetadata } from ' @midwayjs/core' ;
210211import { Context } from ' @midwayjs/koa' ;
211- import { ROLE_META_KEY } from ' ../decorator/role.decorator.ts ' ;
212+ import { ROLE_META_KEY } from ' ../decorator/role.decorator' ;
212213
213214@Guard ()
214215export class AuthGuard implements IGuard <Context > {
@@ -229,9 +230,10 @@ export class AuthGuard implements IGuard<Context> {
229230在路由上使用该守卫。
230231
231232``` typescript
232- import { Controller , Get } from ' @midwayjs/core' ;
233+ import { Controller , Get , UseGuard } from ' @midwayjs/core' ;
233234import { ReportMiddleware } from ' ../middleware/report.middlweare' ;
234235import { AuthGuard } from ' ../guard/auth.guard' ;
236+ import { Role } from ' ../decorator/role.decorator' ;
235237
236238@UseGuard (AuthGuard )
237239@Controller (' /user' )
You can’t perform that action at this time.
0 commit comments