-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Aiden-FE
committed
Apr 1, 2023
1 parent
4dd7b31
commit d794110
Showing
8 changed files
with
27 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { SetMetadata, applyDecorators } from '@nestjs/common'; | ||
import { PERMISSIONS, AUTH_KEY, AuthOption } from '@shared'; | ||
import { ApiBearerAuth } from '@nestjs/swagger'; | ||
|
||
/** | ||
* @description 设置许可权限 | ||
* @param permissions 权限key或keys | ||
* @param mode 权限模式,OR 任一命中即可, AND所有均需满足 | ||
* @constructor | ||
*/ | ||
const Auth = (permissions: PERMISSIONS, mode: AuthOption['mode'] = 'AND') => { | ||
return applyDecorators( | ||
SetMetadata(AUTH_KEY, { | ||
mode, | ||
permissions: Array.isArray(permissions) ? permissions : [permissions], | ||
}), | ||
ApiBearerAuth(), | ||
); | ||
}; | ||
|
||
export default Auth; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters