#1127: hide user e-mail when API caller isn't signed in

This commit is contained in:
Unknwon 2015-07-14 23:21:34 +08:00
parent ec774d48c5
commit 2b1e67e085
2 changed files with 6 additions and 0 deletions

View file

@ -69,6 +69,7 @@ func Toggle(options *ToggleOptions) macaron.Handler {
}
}
// Contexter middleware already checks token for user sign in process.
func ApiReqToken() macaron.Handler {
return func(ctx *Context) {
if !ctx.IsSigned {

View file

@ -68,5 +68,10 @@ func GetUserInfo(ctx *middleware.Context) {
}
return
}
// Hide user e-mail when API caller isn't signed in.
if !ctx.IsSigned {
u.Email = ""
}
ctx.JSON(200, &api.User{u.Id, u.Name, u.FullName, u.Email, u.AvatarLink()})
}