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.
Unknwon 7 years ago
parent
commit
ab634ce61a
5 changed files with 8 additions and 12 deletions
  1. 5 6
      cmd/web.go
  2. 1 1
      gogs.go
  3. 1 1
      modules/auth/auth.go
  4. 0 3
      routers/user/auth.go
  5. 1 1
      templates/.VERSION

+ 5 - 6
cmd/web.go

@@ -230,7 +230,6 @@ func runWeb(ctx *cli.Context) error {
 	})
 
 	m.Group("/user", func() {
-		// r.Get("/feeds", binding.Bind(form.Feeds{}), user.Feeds)
 		m.Any("/activate", user.Activate)
 		m.Any("/activate_email", user.ActivateEmail)
 		m.Get("/email2user", user.Email2User)
@@ -460,7 +459,10 @@ func runWeb(ctx *cli.Context) error {
 	m.Group("/:username/:reponame", func() {
 		m.Get("/issues", repo.RetrieveLabels, repo.Issues)
 		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.
 		// So they can apply their own enable/disable logic on routers.
 		m.Group("/issues", func() {
@@ -477,10 +479,7 @@ func runWeb(ctx *cli.Context) error {
 			m.Post("", repo.UpdateCommentContent)
 			m.Post("/delete", repo.DeleteComment)
 		})
-
-		m.Get("/labels/", repo.RetrieveLabels, repo.Labels)
-		m.Get("/milestones", repo.Milestones)
-	}, ignSignIn, context.RepoAssignment(true))
+	}, reqSignIn, context.RepoAssignment(true))
 	m.Group("/:username/:reponame", func() {
 		m.Group("/wiki", func() {
 			m.Get("/?:page", repo.Wiki)

+ 1 - 1
gogs.go

@@ -16,7 +16,7 @@ import (
 	"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() {
 	setting.AppVer = APP_VER

+ 1 - 1
modules/auth/auth.go

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

+ 0 - 3
routers/user/auth.go

@@ -154,9 +154,6 @@ func SignInPost(ctx *context.Context, f form.SignIn) {
 func SignOut(ctx *context.Context) {
 	ctx.Session.Delete("uid")
 	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.CookieRememberName, "", -1, setting.AppSubUrl)
 	ctx.SetCookie(setting.CSRFCookieName, "", -1, setting.AppSubUrl)

+ 1 - 1
templates/.VERSION

@@ -1 +1 @@
-0.10.33.0329 / 0.11 RC
+0.10.34.0330 / 0.11 RC