mirror of
https://github.com/go-gitea/gitea.git
synced 2024-12-04 14:46:57 -05:00
Redirect to new repository owner (#21398)
Fixes #17655 If you rename `user1` to `user2` and visit `/user1` you get redirected to `/user2`. But if you visit `/user1/repo` you just get a 404 error. With this PR the user is redirected to `/user2/repo`.
This commit is contained in:
parent
2d4c6321c3
commit
8752d89be7
@ -451,11 +451,20 @@ func RepoAssignment(ctx *Context) (cancel context.CancelFunc) {
|
|||||||
owner, err = user_model.GetUserByName(ctx, userName)
|
owner, err = user_model.GetUserByName(ctx, userName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if user_model.IsErrUserNotExist(err) {
|
if user_model.IsErrUserNotExist(err) {
|
||||||
|
// go-get does not support redirects
|
||||||
|
// https://github.com/golang/go/issues/19760
|
||||||
if ctx.FormString("go-get") == "1" {
|
if ctx.FormString("go-get") == "1" {
|
||||||
EarlyResponseForGoGetMeta(ctx)
|
EarlyResponseForGoGetMeta(ctx)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
ctx.NotFound("GetUserByName", nil)
|
|
||||||
|
if redirectUserID, err := user_model.LookupUserRedirect(userName); err == nil {
|
||||||
|
RedirectToUser(ctx, userName, redirectUserID)
|
||||||
|
} else if user_model.IsErrUserRedirectNotExist(err) {
|
||||||
|
ctx.NotFound("GetUserByName", nil)
|
||||||
|
} else {
|
||||||
|
ctx.ServerError("LookupUserRedirect", err)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
ctx.ServerError("GetUserByName", err)
|
ctx.ServerError("GetUserByName", err)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user