diff options
Diffstat (limited to 'routers/api')
-rw-r--r-- | routers/api/v1/repo.go | 5 | ||||
-rw-r--r-- | routers/api/v1/user.go | 5 |
2 files changed, 8 insertions, 2 deletions
diff --git a/routers/api/v1/repo.go b/routers/api/v1/repo.go index d7cc5955..7da5f817 100644 --- a/routers/api/v1/repo.go +++ b/routers/api/v1/repo.go @@ -105,7 +105,8 @@ func createRepo(ctx *middleware.Context, owner *models.User, opt api.CreateRepoO opt.Gitignore, opt.License, opt.Private, false, opt.AutoInit) if err != nil { if err == models.ErrRepoAlreadyExist || - err == models.ErrRepoNameIllegal { + models.IsErrNameReserved(err) || + models.IsErrNamePatternNotAllowed(err) { ctx.JSON(422, &base.ApiJsonErr{err.Error(), base.DOC_URL}) } else { log.Error(4, "CreateRepository: %v", err) @@ -163,7 +164,7 @@ func MigrateRepo(ctx *middleware.Context, form auth.MigrateRepoForm) { } return } - if !u.ValidtePassword(ctx.Query("password")) { + if !u.ValidatePassword(ctx.Query("password")) { ctx.HandleAPI(422, "Username or password is not correct.") return } diff --git a/routers/api/v1/user.go b/routers/api/v1/user.go index e9ba615f..a4648297 100644 --- a/routers/api/v1/user.go +++ b/routers/api/v1/user.go @@ -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()}) } |