From 62edc5c59a3c85f22afd97aa888b4cff26a10d02 Mon Sep 17 00:00:00 2001 From: Unknwon Date: Sat, 9 Jan 2016 13:28:05 +0800 Subject: [PATCH] fix cannot show user public ssh keys --- routers/user/profile.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/routers/user/profile.go b/routers/user/profile.go index 9007ab326f7b..915cf86c61a6 100644 --- a/routers/user/profile.go +++ b/routers/user/profile.go @@ -21,9 +21,8 @@ const ( STARS base.TplName = "user/meta/stars" ) -// GetUserByParams returns user whose name is presented in URL paramenter. -func GetUserByParams(ctx *middleware.Context) *models.User { - user, err := models.GetUserByName(ctx.Params(":username")) +func GetUserByName(ctx *middleware.Context, name string) *models.User { + user, err := models.GetUserByName(name) if err != nil { if models.IsErrUserNotExist(err) { ctx.Error(404) @@ -35,6 +34,11 @@ func GetUserByParams(ctx *middleware.Context) *models.User { return user } +// GetUserByParams returns user whose name is presented in URL paramenter. +func GetUserByParams(ctx *middleware.Context) *models.User { + return GetUserByName(ctx, ctx.Params(":username")) +} + func Profile(ctx *middleware.Context) { uname := ctx.Params(":username") // Special handle for FireFox requests favicon.ico. @@ -51,7 +55,7 @@ func Profile(ctx *middleware.Context) { isShowKeys = true } - u := GetUserByParams(ctx) + u := GetUserByName(ctx, strings.TrimSuffix(uname, ".keys")) if ctx.Written() { return }