Skip to content

Commit

Permalink
feat(example): test guard
Browse files Browse the repository at this point in the history
  • Loading branch information
jiawei397 committed Dec 28, 2021
1 parent a40225c commit 94b23af
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
10 changes: 10 additions & 0 deletions example/guards/auth3.guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,13 @@ export class AuthGuard3 implements CanActivate {
console.log("---test");
}
}

function SSOGuard2() {
return class Guard implements CanActivate {
async canActivate(_context: Context) {
return true;
}
};
}

export const SSOGuard = SSOGuard2();
4 changes: 2 additions & 2 deletions example/user/controllers/user.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ import type { Context } from "../../../mod.ts";
import { BadRequestException, mockjs } from "../../deps.ts";
import { AuthGuard } from "../../guards/auth.guard.ts";
import { AuthGuard2 } from "../../guards/auth2.guard.ts";
import { AuthGuard3 } from "../../guards/auth3.guard.ts";
import { AuthGuard3, SSOGuard } from "../../guards/auth3.guard.ts";
import { RoleAction, Roles } from "../../decorators/roles.ts";
import { LogTime } from "../../decorators/time.ts";

@UseGuards(AuthGuard)
@UseGuards(AuthGuard, SSOGuard)
@Controller("/user")
export class UserController {
@UseGuards(AuthGuard2, AuthGuard3)
Expand Down

0 comments on commit 94b23af

Please sign in to comment.