fix(communities): only require auth for token gated communities

There's a bug that all requests to join a community require the user to
authenticate themselves. This should only be needed for community that
are token permissioned.

This commit fixes it by only performing auth when requesting from the
tokengated community view.

Fixes #10010
This commit is contained in:
Pascal Precht 2023-03-24 14:54:59 +01:00 committed by Jonathan Rainville
parent 27d7b822e3
commit 81d4ea05e9
5 changed files with 14 additions and 1 deletions

View File

@ -390,3 +390,6 @@ method requestToJoinCommunity*(self: AccessInterface, communityId: string, ensNa
method onDeactivateChatLoader*(self: AccessInterface, chatId: string) =
raise newException(ValueError, "No implementation available")
method requestToJoinCommunityWithAuthentication*(self: AccessInterface, communityId: string, ensName: string) =
raise newException(ValueError, "No implementation available")

View File

@ -1234,6 +1234,9 @@ method deleteCommunityTokenPermission*(self: Module, communityId: string, permis
self.controller.deleteCommunityTokenPermission(communityId, permissionId)
method requestToJoinCommunity*(self: Module, communityId: string, ensName: string) =
self.controller.requestToJoinCommunity(communityId, ensName)
method requestToJoinCommunityWithAuthentication*(self: Module, communityId: string, ensName: string) =
self.controller.authenticateToRequestToJoinCommunity(communityId, ensName)
proc buildTokenPermissionItem*(self: Module, tokenPermission: CommunityTokenPermissionDto): TokenPermissionItem =

View File

@ -259,6 +259,9 @@ QtObject:
proc requestToJoinCommunity*(self: View, communityId: string, ensName: string) {.slot.} =
self.delegate.requestToJoinCommunity(communityId, ensName)
proc requestToJoinCommunityWithAuthentication*(self: View, communityId: string, ensName: string) {.slot.} =
self.delegate.requestToJoinCommunityWithAuthentication(communityId, ensName)
proc joinGroupChatFromInvitation*(self: View, groupName: string, chatId: string, adminPK: string) {.slot.} =
self.delegate.joinGroupChatFromInvitation(groupName, chatId, adminPK)

View File

@ -101,7 +101,7 @@ StackLayout {
accessType: communityData.access
onJoined: {
root.rootStore.requestToJoinCommunity(communityData.id, root.rootStore.userProfileInst.name)
root.rootStore.requestToJoinCommunityWithAuthentication(communityData.id, root.rootStore.userProfileInst.name)
}
onCancelMembershipRequest: {

View File

@ -411,6 +411,10 @@ QtObject {
chatCommunitySectionModule.requestToJoinCommunity(id, ensName)
}
function requestToJoinCommunityWithAuthentication(id, ensName) {
chatCommunitySectionModule.requestToJoinCommunityWithAuthentication(id, ensName)
}
function userCanJoin(id) {
return communitiesModuleInst.userCanJoin(id)
}