mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-22 08:42:32 -05:00
22a0636544
You can limit or hide organisations. This pull make it also posible for users - new strings to translte - add checkbox to user profile form - add checkbox to admin user.edit form - filter explore page user search - filter api admin and public user searches - allow admins view "hidden" users - add app option DEFAULT_USER_VISIBILITY - rewrite many files to use Visibility field - check for teams intersection - fix context output - right fake 404 if not visible Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: Andrew Thornton <art27@cantab.net>
36 lines
1,001 B
Go
36 lines
1,001 B
Go
// Copyright 2021 The Gitea Authors.
|
|
// Use of this source code is governed by a MIT-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package user
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"code.gitea.io/gitea/models"
|
|
"code.gitea.io/gitea/modules/context"
|
|
)
|
|
|
|
// GetUserByParamsName get user by name
|
|
func GetUserByParamsName(ctx *context.APIContext, name string) *models.User {
|
|
username := ctx.Params(name)
|
|
user, err := models.GetUserByName(username)
|
|
if err != nil {
|
|
if models.IsErrUserNotExist(err) {
|
|
if redirectUserID, err2 := models.LookupUserRedirect(username); err2 == nil {
|
|
context.RedirectToUser(ctx.Context, username, redirectUserID)
|
|
} else {
|
|
ctx.NotFound("GetUserByName", err)
|
|
}
|
|
} else {
|
|
ctx.Error(http.StatusInternalServerError, "GetUserByName", err)
|
|
}
|
|
return nil
|
|
}
|
|
return user
|
|
}
|
|
|
|
// GetUserByParams returns user whose name is presented in URL (":username").
|
|
func GetUserByParams(ctx *context.APIContext) *models.User {
|
|
return GetUserByParamsName(ctx, ":username")
|
|
}
|