Default behavior of invitation when a logged-in user accepts a new invitation

Community Server

Group for Content about my AlexCrome.CS addon package for Community Server 2008

Default behavior of invitation when a logged-in user accepts a new invitation

Answered (Verified) This question is answered

Sorry, I may have posted too many times in http://alexcrome.co.uk/blogs/community_server/alexcrome-cs-2008-5.aspx  I'll just paste it here:

================================================================

I went through the process again:

 

1. login as marty1101(2100)

2. Accepts an invitation from admin(2104) and register a new user: watcher (2132)

3. After the invitation is accepted, the logged-in user is still marty1101(2100).  and no new entry in Table: ac_UserReferals

 

The one minute window did the trick.  However, if marty1101 was registered within the last minute.  A new entry in TAble: ac_UserReferals would be NewUserID=2100(marty1101) instead of NewUserID=2132(watcher)

 

I know this is unlikely to happen, but it still an uncertainty.

 

Actually, I wrote a similar csa_UserInvitationAccepted() before discovering your add-on.  The behavior I expected was:

after a logged-in user (marty1101) accepted an invitation, the logged-in user should be the newly created user (watcher) instead of the user (marty1101) who accepted the invitation.  It's more intuitive to me.

 

so I made the change to the source code (\CommunityServer.Controls\Forms\CreateUserForm.cs) and it behaves as expected.

 

The default behavior leaves me no access to the newly registered User in csa_UserInvitationAccepted(); and it is needed for other purposes.

 

I can't think of a reason why CS designed it this way and its intention.  Could you elaborate more on this?

 

Let's say a friend issued more than one invitations to me.  I logged in after accepting the 1st one; and accidently accepts the 2nd one (create another new user).  Now I'm logged-in as the first username; and I forgot what username(2nd one) I just registered.  Or, I didn't like the first username and forgot to log out before registering the 2nd username ...

 

The final version of my code is to make the change to \CommunityServer.Controls\Forms\CreateUserForm.cs.  and in csa_UserInvitationAccepted(), I check if the new UserID exists in the referral table, and only create a new entry when not.  (ps. I use this referral table for the purpose of multi-level marketing father-son relationship)

 

Hopefully I explain it well.  It's quite complicated for me when I discovered the default behavior at the first place.

 

 

  • Post Points: 20
Verified Answer
  • First a point to make about invitations - there are two reasons invitations are sent out

    1. Someone is invited to join the community
    2. Someone is invited to join a group (typically a private group)

    With the second type of invitation, that invitation can go out to an existing member, or a new member.  This means that invitations can be created by existing users.  For my addon to determine whetehr the user is new member who was just signed up, or an existing member I check whetehr the user was created within the past minute.

    In your above scenario, the reason you get no access to the new user in the csa_UserInvitationAccepted event is because the new user never accepts the invitation.  The invitation is accepted by marty1101 in step 2.  However the case you're describing is very much an edge case - how often will an existing member create a new account when they're already logged in.  The only situation that's going to happen is if an admin is bulk creating new users, but if he's doing and he wants the members to accept invitations, he should just send out invitations to those members and let them register themselves.

    • Top 10 Contributor
    • Male
    • Post Points: 70
All Replies
  • Thank you for the detailed explanations.  I didn't know invitations also works in group invitations and I misunderstood the logic of the default behavior.

    Although the odds is low, to prevent a logged-in user from accepting an invitation to create a new user, I could only think of blocking the execution of createuser.aspx because all User CSModule Events are after a new user is created.

    • Top 10 Contributor
    • Post Points: 20
  • Invitations aren't accepted on createuser.aspx - they are accepted on acceptinvitation.aspx.  If an existing user accepts an invitation that invites them to join the site, nothing will happen unless they accept a second invitation within one minute of registering in which case the referal will be logged twice.

    • Top 10 Contributor
    • Male
    • Post Points: 20
  • Oops!  I made a terrible mistake to note down createuser.aspx as the starting point during debugging.  All concerns became non-sense.  The default behavior is sound.  Sorry for taking your time.

    One last thing is to delete the ac_UserReferals entry after a user is deleted.  Well, this might not be necessary though ...

    • Top 10 Contributor
    • Post Points: 5
Page 1 of 1 (5 items)