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

Fix 404 error when remove self from an organization #26362

Merged
merged 6 commits into from
Aug 12, 2023

Conversation

yp05327
Copy link
Member

@yp05327 yp05327 commented Aug 7, 2023

Same to #24322

Not only leave action but also remove action should check whether user still belongs to the org.

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Aug 7, 2023
@pull-request-size pull-request-size bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Aug 7, 2023
Copy link
Contributor

@wxiaoguang wxiaoguang left a comment

Choose a reason for hiding this comment

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

Overall LGTM. ps: there is a handy function: ctx.JSONRedirect(....)

@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Aug 7, 2023
routers/web/org/teams.go Outdated Show resolved Hide resolved
routers/web/org/teams.go Outdated Show resolved Hide resolved
yp05327 and others added 2 commits August 7, 2023 15:55
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Aug 7, 2023
@lunny lunny added reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. topic/ui-interaction Change the process how users use Gitea instead of the visual appearance labels Aug 7, 2023
@lunny lunny enabled auto-merge (squash) August 7, 2023 10:46
Comment on lines 128 to 139
redirect := ctx.Org.OrgLink + "/teams/" + url.PathEscape(ctx.Org.Team.LowerName)
if isOrgMember, err := org_model.IsOrganizationMember(ctx, ctx.Org.Organization.ID, ctx.Doer.ID); err != nil {
ctx.ServerError("IsOrganizationMember", err)
return
} else if !isOrgMember {
if ctx.Org.Organization.Visibility.IsPrivate() {
redirect = setting.AppSubURL + "/"
} else {
redirect = ctx.Org.Organization.HomeLink()
}
}
ctx.JSONRedirect(redirect)
Copy link
Member

@delvh delvh Aug 7, 2023

Choose a reason for hiding this comment

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

What about extracting this check into a separate method and giving it a parameter defaultRedirect?
You call it twice at the moment (90-101 and 128-139).

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

@delvh delvh disabled auto-merge August 7, 2023 11:03
@delvh delvh removed the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Aug 7, 2023
@pull-request-size pull-request-size bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Aug 8, 2023
@wxiaoguang wxiaoguang enabled auto-merge (squash) August 12, 2023 06:36
@wxiaoguang wxiaoguang merged commit 9fc68b6 into go-gitea:main Aug 12, 2023
23 checks passed
@GiteaBot GiteaBot added this to the 1.21.0 milestone Aug 12, 2023
zjjhot added a commit to zjjhot/gitea that referenced this pull request Aug 14, 2023
* upstream/main: (24 commits)
  Update zh-cn documentation (go-gitea#26406)
  Fix NuGet search endpoints (go-gitea#25613)
  Fix tooltip of commit select button (go-gitea#26472)
  fix grab cursor on default column (go-gitea#26476)
  Fix storage path logic especially for relative paths (go-gitea#26441)
  Rename `Sync2` -> `Sync` (go-gitea#26479)
  Add ThreadID parameter for Telegram webhooks (go-gitea#25996)
  Fix stderr usages (go-gitea#26477)
  Use correct pull request commit link instead of a generic commit link (go-gitea#26434)
  Close stdout correctly for "git blame" (go-gitea#26470)
  Refactor tests (go-gitea#26464)
  Remove last newline from config file (go-gitea#26468)
  Add matrix to support (go-gitea#26382)
  Refactor project templates (go-gitea#26448)
  Avoiding accessing undefined mentionValues (go-gitea#26461)
  Tweak actions menu (go-gitea#26278)
  Adjust minio new sequence, now it will check whether bucket exist first and then create one if it doesn't exist (go-gitea#26420)
  Set commit id when ref used explicitly (go-gitea#26447)
  Fix 404 error when remove self from an organization (go-gitea#26362)
  Update index doc (go-gitea#26455)
  ...
@yp05327 yp05327 deleted the fix-404-when-remove-self-from-org branch August 15, 2023 02:29
@go-gitea go-gitea locked as resolved and limited conversation to collaborators Nov 10, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. topic/ui-interaction Change the process how users use Gitea instead of the visual appearance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants