gitea icon indicating copy to clipboard operation
gitea copied to clipboard

Add team member invite by email

Open KN4CK3R opened this issue 3 years ago • 5 comments

Allows to add (not registered) team members by email.

related #5353

Invite by mail: grafik

Pending invitations: grafik

Email: grafik

Join form: grafik

KN4CK3R avatar Jul 10 '22 17:07 KN4CK3R

I opened https://github.com/KN4CK3R/gitea/pull/2 to add a check to see if the invite email corresponds to a user that has already joined a team. I've also included a few unit tests. I'll also try to add an integration test for the login/redirect behavior.

jackHay22 avatar Jul 11 '22 18:07 jackHay22

FAIL: TestOrgTeamEmailInvite (1.55s)

    testlogger.go:78: 2022/08/10 00:31:50 ...eb/routing/logger.go:99:func1() [I] [62f2fc76] router: completed GET /org/user3/teams/team1 for , 200 OK in 32.1ms @ org/teams.go:352(org.TeamMembers)

    testlogger.go:78: 2022/08/10 00:31:50 ...eb/routing/logger.go:99:func1() [I] [62f2fc76-2] router: completed POST /org/user3/teams/team1/action/add for , 303 See Other in 16.6ms @ org/teams.go:64(org.TeamsAction)

    testlogger.go:78: 2022/08/10 00:31:51 ...eb/routing/logger.go:99:func1() [I] [62f2fc76-3] router: completed GET /org/user3/teams/team1 for , 200 OK in 30.1ms @ org/teams.go:352(org.TeamMembers)

    org_team_invite_test.go:42: 

        	Error Trace:	org_team_invite_test.go:42

        	Error:      	"[]" should have 1 item(s), but has 0

        	Test:       	TestOrgTeamEmailInvite

6543 avatar Aug 10 '22 12:08 6543

Should work now. The test failed because there is no mail service configured for the mysql8 test.

KN4CK3R avatar Aug 10 '22 19:08 KN4CK3R

Once you've entered some text into the field and try to leave, the annoying

That's the current behaviour and not related to this PR.

KN4CK3R avatar Sep 07 '22 18:09 KN4CK3R

Once you've entered some text into the field and try to leave, the annoying

That's the current behaviour and not related to this PR.

@delvh see #21154

KN4CK3R avatar Sep 13 '22 10:09 KN4CK3R

FYI I tested this an it works nicely!

Screen Shot 2022-10-10 at 6 15 59 PM

The only weird behavior I noticed is that if you do not already have an account on the instance, clicking the email link does nothing. You first have to sign up for a new account, and then click the email link to be added to the team. On a server with registrations disabled, this means that inviting new users wouldn't actually allow people to accept the invite.

Reading the initial issue and another related issue, I had assumed this functionality would automatically bring the user to the registration page with their email pre-filled. I had also assumed existing users would be able to invite other users by email to either:

  • the entire instance itself
  • the specific organization team

Either way, I consider this PR an improvement and could easily pave the way for the aforementioned functionality in the near future! 😄

Nezteb avatar Oct 11 '22 01:10 Nezteb

The only weird behavior I noticed is that if you do not already have an account on the instance, clicking the email link does nothing. You first have to sign up for a new account, and then click the email link to be added to the team.

That should work. Tested it right now. You open the link from the mail and see the login page. There you register a new account and after that you automaticaly get redirected to the "join team" page. Here is a (german) screenshot with the "account created" notification still present: grafik

On a server with registrations disabled, this means that inviting new users wouldn't actually allow people to accept the invite.

Should this feature be disabled if registrations are disabled? Make sense because this feature aims at users which are not registered.

KN4CK3R avatar Oct 11 '22 18:10 KN4CK3R

That should work. Tested it right now. You open the link from the mail and see the login page. There you register a new account and after that you automaticaly get redirected to the "join team" page.

I don't remember if I got redirected after register, but I had assumed that something wasn't working right because I didn't see any UI elements or URL params indicating that my invite link had worked properly. I got redirected to the sign in screen, not the registration screen. 😅 I'll give it another try though!

Should this feature be disabled if registrations are disabled? Make sense because this feature aims at users which are not registered.

Worst case scenario: an admin disables registrations, another admin invites a non-registered user to a team, the non-registered user clicks the links, the user is brought to the sign in page, the user sees no option to register, and the user gives up confused. I don't know how often that kind of thing would occur.

In the future it'd be nice to have registrations disabled but also allow admins to individually invite users who can then register (since they were explicitly invited).

Nezteb avatar Oct 11 '22 21:10 Nezteb

In the future it'd be nice to have registrations disabled but also allow admins to individually invite users who can then register (since they were explicitly invited).

I added an new issue for that: https://github.com/go-gitea/gitea/issues/21419

KN4CK3R avatar Oct 12 '22 06:10 KN4CK3R

I think in future we could extend this feature to implement the "user have to accept to be added to an org/team :) - not now

if one do know the issue index ... would be good to link that issue to this pull

6543 avatar Oct 16 '22 17:10 6543

@KN4CK3R please resolve conflicts :)

6543 avatar Oct 17 '22 22:10 6543

followup #21511

6543 avatar Oct 19 '22 12:10 6543