Skip to content

Instantly share code, notes, and snippets.

@ms314006
Created August 5, 2023 08:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ms314006/5f2c5c75beca5f7343fcbcc39405ccfd to your computer and use it in GitHub Desktop.
Save ms314006/5f2c5c75beca5f7343fcbcc39405ccfd to your computer and use it in GitHub Desktop.
// 取得資料
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