Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should not access group after being leaved #1728

Conversation

Silver-IT
Copy link
Member

@Silver-IT Silver-IT commented Sep 18, 2023

@Silver-IT Silver-IT requested a review from taoeffect September 18, 2023 23:38
@Silver-IT Silver-IT self-assigned this Sep 18, 2023
@Silver-IT Silver-IT linked an issue Sep 18, 2023 that may be closed by this pull request
@Silver-IT Silver-IT marked this pull request as draft September 18, 2023 23:39
@Silver-IT Silver-IT changed the base branch from master to e2e-protocol September 18, 2023 23:49
@Silver-IT Silver-IT marked this pull request as ready for review September 18, 2023 23:51
Copy link
Member

@taoeffect taoeffect left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@corrideat

Could you test this PR and try it out?

The PR seems to fix the issue, but after the last step in #1716 I get this error:

Screenshot 2023-10-12 at 1 20 05 PM

Should I approve and merge anyway as-is?

@taoeffect taoeffect requested a review from corrideat October 12, 2023 21:14
Copy link
Member

@corrideat corrideat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need to test this

if (rootState.contracts[params.contractID]?.type !== 'gi.contracts/group') {
if (!rootState.contracts[params.contractID]) {
// NOTE: already kicked from the group by someone else
return
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This return looks like it'd fix the issue

@@ -316,7 +316,9 @@ export default (sbp('sbp/selectors/register', {
// action if we haven't done so yet (because we were previously waiting for
// the keys), or (c) already a member and ready to interact with the group.
'gi.actions/group/join': async function (params: $Exact<ChelKeyRequestParams> & { options?: { skipUsableKeysCheck?: boolean; skipInviteAccept?: boolean } }) {
sbp('okTurtles.data/set', 'JOINING_GROUP-' + params.contractID, true)
if (!params.options?.skipInviteAccept) {
sbp('okTurtles.data/set', 'JOINING_GROUP-' + params.contractID, true)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need to test this, but I'd think it breaks waiting for an invite upon logging in (i.e., logging in before the keys have been received).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'JOINING_GROUP-${contractID}' is being used inside the sideEffect functions of group contracts.
It should be true only when joining group, not when try to log in or to see if the user has key.
That's why I added if conditional statement.

@@ -524,6 +527,7 @@ export default (sbp('sbp/selectors/register', {
console.error('gi.actions/group/join failed!', e)
throw new GIErrorUIRuntimeError(L('Failed to join the group: {codeError}', { codeError: e.message }))
} finally {
sbp('okTurtles.data/set', 'JOINING_GROUP-' + params.contractID, false)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function returning does not mean that the joining process is complete. It's complete when keys are received.

@corrideat
Copy link
Member

corrideat commented Oct 12, 2023

I was able to reproduce, and I now need to text this PR. However, I expect it'd break in the following case:

  1. U1 creates a group
  2. U2 joins
  3. U3 joins and immediately leaves
  4. U1 and U2 close the browser
  5. U3 joins again (is left at pending)
  6. U3 logs out and closes the browser
  7. (Optionally, U1 or U2 reopen GI)
  8. U3 logs in again

Personally, I'd go with something like this:

diff --git a/frontend/controller/actions/group.js b/frontend/controller/actions/group.js
index bde4403e..65ecd0a6 100644
--- a/frontend/controller/actions/group.js
+++ b/frontend/controller/actions/group.js
@@ -513,6 +513,15 @@ export default (sbp('sbp/selectors/register', {
         }
 
         sbp('okTurtles.data/set', 'JOINING_GROUP-' + params.contractID, false)
+      // We don't have the group secret keys, we're not waiting for a key
+      // share and we're marked as having left. This means we synced the contract
+      // and we've been kicked out
+      } else if (!hasSecretKeys && !sbp('chelonia/contract/isWaitingForKeyShare', state) && state.profiles[username].departedDate) {
+        sbp('okTurtles.data/set', 'JOINING_GROUP-' + params.contractID, false)
+        // DO SOMETHING HERE
+        // SOMETHING MEANS: Separate the logic for leaving, so that we can do it
+        // even if it's not an action we're processing in contracts/group.js
+
       // We have already sent a key request that hasn't been answered. We cannot
       // do much at this point, so we do nothing.
       // This could happen, for example, after logging in if we still haven't

@corrideat
Copy link
Member

corrideat commented Oct 13, 2023

I've tested this PR, and it fails under simpler scenarios than I described. For example,

  1. [BROWSER 1] u1 creates group
  2. [BROWSER 2] u2 joins group
  3. [BROWSER 1] u1 removes u2 from group
  4. [BROWSER 2] u2 rejoins group, closes browser
  5. [BROWSER 3] u2 logs in

@taoeffect taoeffect added the Note:Reassigned These PRs have been reassigned to someone else label Oct 20, 2023
Copy link
Member Author

@Silver-IT Silver-IT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ready for your reviews, @taoeffect, @corrideat.

@taoeffect
Copy link
Member

Closing in favor of recent changes in e2e-protocol and e2e-protocol-ricardo.

@taoeffect taoeffect closed this Jan 11, 2024
@Silver-IT Silver-IT deleted the 1716-should-not-be-accessible-to-the-group-unless-group-member-tries branch March 7, 2024 07:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Note:Reassigned These PRs have been reassigned to someone else
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Should not be accessible to the group unless group member tries
4 participants