Created
August 5, 2023 08:10
-
-
Save ms314006/5f2c5c75beca5f7343fcbcc39405ccfd to your computer and use it in GitHub Desktop.
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
// 取得資料 | |
const { refetch: fetchUserProfile } = useUserProfile(userId); | |
const userProfile = await fetchUserProfile(); | |
// 建立檢查權限的邏輯 | |
const userPermissionHandler = new UserPermissionHandler(userProfile); | |
// 將要檢查的權限放到 guards 裡面 | |
const guards = new Guards(); | |
guard.addGuards([ | |
{ isValid: userPermissionHandler.isLogin }, | |
{ isValid: userPermissionHandler.isMobileVerified }, | |
{ isValid: userPermissionHandler.isEmailVerified } | |
]); | |
// 得到檢查結果~~ | |
const { isValid } = guards.execute(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment