File tree Expand file tree Collapse file tree 1 file changed +13
-4
lines changed
astro-authproto/__example__/src/pages Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Original file line number Diff line number Diff line change 22import Login from " ../../../dist/components/Login.astro" ;
33import {AtpBaseClient } from " @atproto/api" ;
44
5- const SITE_OWNER_DID = " did:plc:dg2qmmjic7mmecrbvpuhtvh6" ;
5+ const MS_BOBA_DID = " did:plc:r2vpg2iszskbkegoldmqa322" ;
6+ const HAETAE_DID = " did:plc:dg2qmmjic7mmecrbvpuhtvh6" ;
7+ const FUJOCODED_DID = " did:plc:737bslnnf7vyaktosjlrshmd" ;
68const user = Astro .locals .loggedInUser ;
79if (! user ?.did ) {
810 return Astro .redirect (" /?reason=unauthorized" );
911}
1012const agent = new AtpBaseClient (" https://public.api.bsky.app" );
11- const following = await agent .app .bsky .graph .getFollows ({actor: SITE_OWNER_DID });
12- const isFollowed = following .data .follows . some ( follow => follow . did === user . did );
13+ const relationships = await agent .app .bsky .graph .getRelationships ({actor: FUJOCODED_DID , others: [ user . did ] });
14+ const usersRelationship = relationships .data .relationships . at ( 0 );
1315
14- if (! isFollowed ) {
16+ // True if the current user follows you
17+ const follower = usersRelationship && " followedBy" in usersRelationship && Boolean (usersRelationship .followedBy );
18+ // True if you follow the current user
19+ const following = usersRelationship && " following" in usersRelationship && Boolean (usersRelationship .following );
20+ // True if this is a mutual relationship
21+ const mutuals = follower && following ;
22+
23+ if (! following ) {
1524 return Astro .redirect (" /?reason=unauthorized" );
1625}
1726---
You can’t perform that action at this time.
0 commit comments