Merge f9534cda01
into ae9dd239fb
This commit is contained in:
commit
c216fe4e75
|
@ -684,7 +684,7 @@ func NewGhostUser() *User {
|
|||
|
||||
var (
|
||||
reservedUsernames = []string{"assets", "css", "explore", "img", "js", "less", "plugins", "debug", "raw", "install", "api", "avatars", "user", "org", "help", "stars", "issues", "pulls", "commits", "repo", "template", "admin", "error", "new", ".", ".."}
|
||||
reservedUserPatterns = []string{"*.keys"}
|
||||
reservedUserPatterns = []string{"*.keys", "*.gpg"}
|
||||
)
|
||||
|
||||
// isUsableName checks if name is reserved or pattern of name is not allowed
|
||||
|
|
|
@ -354,6 +354,22 @@ func ShowSSHKeys(ctx *context.Context, uid int64) {
|
|||
ctx.PlainText(200, buf.Bytes())
|
||||
}
|
||||
|
||||
// ShowGPGKeys output all the public GPG keys of user by uid
|
||||
func ShowGPGKeys(ctx *context.Context, uid int64) {
|
||||
keys, err := models.ListGPGKeys(uid)
|
||||
if err != nil {
|
||||
ctx.ServerError("ListGPGKeys", err)
|
||||
return
|
||||
}
|
||||
|
||||
var buf bytes.Buffer
|
||||
for i := range keys {
|
||||
buf.WriteString(keys[i])
|
||||
buf.WriteString("\n")
|
||||
}
|
||||
ctx.PlainText(200, buf.Bytes())
|
||||
}
|
||||
|
||||
func showOrgProfile(ctx *context.Context) {
|
||||
ctx.SetParams(":org", ctx.Params(":username"))
|
||||
context.HandleOrgAssignment(ctx)
|
||||
|
|
|
@ -58,9 +58,16 @@ func Profile(ctx *context.Context) {
|
|||
isShowKeys := false
|
||||
if strings.HasSuffix(uname, ".keys") {
|
||||
isShowKeys = true
|
||||
uname = strings.TrimSuffix(uname, ".gpg")
|
||||
}
|
||||
|
||||
ctxUser := GetUserByName(ctx, strings.TrimSuffix(uname, ".keys"))
|
||||
isShowGPG := false
|
||||
if strings.HasSuffix(uname, ".gpg") {
|
||||
isShowGPG = true
|
||||
uname = strings.TrimSuffix(uname, ".gpg")
|
||||
}
|
||||
|
||||
ctxUser := GetUserByName(ctx, uname)
|
||||
if ctx.Written() {
|
||||
return
|
||||
}
|
||||
|
@ -71,6 +78,12 @@ func Profile(ctx *context.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
// Show GPG keys.
|
||||
if isShowGPG {
|
||||
ShowGPGKeys(ctx, ctxUser.ID)
|
||||
return
|
||||
}
|
||||
|
||||
if ctxUser.IsOrganization() {
|
||||
showOrgProfile(ctx)
|
||||
return
|
||||
|
|
Loading…
Reference in New Issue
Block a user