gitea
gitea copied to clipboard
Add team member invite by email
Allows to add (not registered) team members by email.
related #5353
Invite by mail:

Pending invitations:

Email:

Join form:

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.
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
Should work now. The test failed because there is no mail service configured for the mysql8 test.
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.
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
FYI I tested this an it works nicely!
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! 😄
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:

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.
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).
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
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
@KN4CK3R please resolve conflicts :)
followup #21511