Browse Source

cmd/web: fix routes requires sign in (#4359)

Redirect user to sign in page when visit private repository with
public issues if user want to post comment or create new issue.
pull/3696/merge
Unknwon 8 years ago
parent
commit
ab634ce61a
No known key found for this signature in database
GPG Key ID: 25B575AE3213B2B3
  1. 11
      cmd/web.go
  2. 2
      gogs.go
  3. 2
      modules/auth/auth.go
  4. 3
      routers/user/auth.go
  5. 2
      templates/.VERSION

11
cmd/web.go

@ -230,7 +230,6 @@ func runWeb(ctx *cli.Context) error {
}) })
m.Group("/user", func() { m.Group("/user", func() {
// r.Get("/feeds", binding.Bind(form.Feeds{}), user.Feeds)
m.Any("/activate", user.Activate) m.Any("/activate", user.Activate)
m.Any("/activate_email", user.ActivateEmail) m.Any("/activate_email", user.ActivateEmail)
m.Get("/email2user", user.Email2User) m.Get("/email2user", user.Email2User)
@ -460,7 +459,10 @@ func runWeb(ctx *cli.Context) error {
m.Group("/:username/:reponame", func() { m.Group("/:username/:reponame", func() {
m.Get("/issues", repo.RetrieveLabels, repo.Issues) m.Get("/issues", repo.RetrieveLabels, repo.Issues)
m.Get("/issues/:index", repo.ViewIssue) m.Get("/issues/:index", repo.ViewIssue)
m.Get("/labels/", repo.RetrieveLabels, repo.Labels)
m.Get("/milestones", repo.Milestones)
}, ignSignIn, context.RepoAssignment(true))
m.Group("/:username/:reponame", func() {
// FIXME: should use different URLs but mostly same logic for comments of issue and pull reuqest. // FIXME: should use different URLs but mostly same logic for comments of issue and pull reuqest.
// So they can apply their own enable/disable logic on routers. // So they can apply their own enable/disable logic on routers.
m.Group("/issues", func() { m.Group("/issues", func() {
@ -477,10 +479,7 @@ func runWeb(ctx *cli.Context) error {
m.Post("", repo.UpdateCommentContent) m.Post("", repo.UpdateCommentContent)
m.Post("/delete", repo.DeleteComment) m.Post("/delete", repo.DeleteComment)
}) })
}, reqSignIn, context.RepoAssignment(true))
m.Get("/labels/", repo.RetrieveLabels, repo.Labels)
m.Get("/milestones", repo.Milestones)
}, ignSignIn, context.RepoAssignment(true))
m.Group("/:username/:reponame", func() { m.Group("/:username/:reponame", func() {
m.Group("/wiki", func() { m.Group("/wiki", func() {
m.Get("/?:page", repo.Wiki) m.Get("/?:page", repo.Wiki)

2
gogs.go

@ -16,7 +16,7 @@ import (
"github.com/gogits/gogs/modules/setting" "github.com/gogits/gogs/modules/setting"
) )
const APP_VER = "0.10.33.0329 / 0.11 RC" const APP_VER = "0.10.34.0330 / 0.11 RC"
func init() { func init() {
setting.AppVer = APP_VER setting.AppVer = APP_VER

2
modules/auth/auth.go

@ -67,7 +67,7 @@ func SignedInID(ctx *macaron.Context, sess session.Store) int64 {
if id, ok := uid.(int64); ok { if id, ok := uid.(int64); ok {
if _, err := models.GetUserByID(id); err != nil { if _, err := models.GetUserByID(id); err != nil {
if !errors.IsUserNotExist(err) { if !errors.IsUserNotExist(err) {
log.Error(2, "GetUserById: %v", err) log.Error(2, "GetUserByID: %v", err)
} }
return 0 return 0
} }

3
routers/user/auth.go

@ -154,9 +154,6 @@ func SignInPost(ctx *context.Context, f form.SignIn) {
func SignOut(ctx *context.Context) { func SignOut(ctx *context.Context) {
ctx.Session.Delete("uid") ctx.Session.Delete("uid")
ctx.Session.Delete("uname") ctx.Session.Delete("uname")
ctx.Session.Delete("socialId")
ctx.Session.Delete("socialName")
ctx.Session.Delete("socialEmail")
ctx.SetCookie(setting.CookieUserName, "", -1, setting.AppSubUrl) ctx.SetCookie(setting.CookieUserName, "", -1, setting.AppSubUrl)
ctx.SetCookie(setting.CookieRememberName, "", -1, setting.AppSubUrl) ctx.SetCookie(setting.CookieRememberName, "", -1, setting.AppSubUrl)
ctx.SetCookie(setting.CSRFCookieName, "", -1, setting.AppSubUrl) ctx.SetCookie(setting.CSRFCookieName, "", -1, setting.AppSubUrl)

2
templates/.VERSION

@ -1 +1 @@
0.10.33.0329 / 0.11 RC 0.10.34.0330 / 0.11 RC
Loading…
Cancel
Save