summaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
Diffstat (limited to 'routers')
-rw-r--r--routers/repo/issue.go35
-rw-r--r--routers/user/auth.go45
2 files changed, 39 insertions, 41 deletions
diff --git a/routers/repo/issue.go b/routers/repo/issue.go
index 49f788e4a9..c4903a929f 100644
--- a/routers/repo/issue.go
+++ b/routers/repo/issue.go
@@ -427,7 +427,7 @@ func ViewIssue(ctx *middleware.Context) {
ctx.Data["Title"] = issue.Name
if err = issue.GetPoster(); err != nil {
- ctx.Handle(500, "GetPoster: %v", err)
+ ctx.Handle(500, "GetPoster", err)
return
}
issue.RenderedContent = string(base.RenderMarkdown([]byte(issue.Content), ctx.Repo.RepoLink))
@@ -441,7 +441,7 @@ func ViewIssue(ctx *middleware.Context) {
if ctx.IsSigned {
// Update issue-user.
if err = issue.ReadBy(ctx.User.Id); err != nil {
- ctx.Handle(500, "ReadBy: %v", err)
+ ctx.Handle(500, "ReadBy", err)
return
}
@@ -475,10 +475,35 @@ func ViewIssue(ctx *middleware.Context) {
}
}
+ var (
+ repo = ctx.Repo.Repository
+ tag models.CommentTag
+ ok bool
+ marked = make(map[int64]models.CommentTag)
+ comment *models.Comment
+ )
// Render comments.
- for i := range issue.Comments {
- if issue.Comments[i].Type == models.COMMENT_TYPE_COMMENT {
- issue.Comments[i].RenderedContent = string(base.RenderMarkdown([]byte(issue.Comments[i].Content), ctx.Repo.RepoLink))
+ for _, comment = range issue.Comments {
+ if comment.Type == models.COMMENT_TYPE_COMMENT {
+ comment.RenderedContent = string(base.RenderMarkdown([]byte(comment.Content), ctx.Repo.RepoLink))
+
+ // Check tag.
+ tag, ok = marked[comment.PosterID]
+ if ok {
+ comment.ShowTag = tag
+ continue
+ }
+
+ if repo.IsOwnedBy(comment.PosterID) ||
+ (repo.Owner.IsOrganization() && repo.Owner.IsOwnedBy(comment.PosterID)) {
+ comment.ShowTag = models.COMMENT_TAG_OWNER
+ } else if comment.Poster.IsAdminOfRepo(repo) {
+ comment.ShowTag = models.COMMENT_TAG_ADMIN
+ } else if comment.PosterID == issue.PosterID {
+ comment.ShowTag = models.COMMENT_TAG_POSTER
+ }
+
+ marked[comment.PosterID] = comment.ShowTag
}
}
diff --git a/routers/user/auth.go b/routers/user/auth.go
index 4b29a29ec8..61e572f9bc 100644
--- a/routers/user/auth.go
+++ b/routers/user/auth.go
@@ -42,49 +42,22 @@ func SignIn(ctx *middleware.Context) {
}
// Check auto-login.
- uname := ctx.GetCookie(setting.CookieUserName)
- if len(uname) == 0 {
- ctx.HTML(200, SIGNIN)
- return
- }
-
- isSucceed := false
- defer func() {
- if !isSucceed {
- log.Trace("auto-login cookie cleared: %s", uname)
- ctx.SetCookie(setting.CookieUserName, "", -1, setting.AppSubUrl)
- ctx.SetCookie(setting.CookieRememberName, "", -1, setting.AppSubUrl)
- return
- }
- }()
-
- u, err := models.GetUserByName(uname)
+ isSucceed, err := middleware.AutoSignIn(ctx)
if err != nil {
- if !models.IsErrUserNotExist(err) {
- ctx.Handle(500, "GetUserByName", err)
- } else {
- ctx.HTML(200, SIGNIN)
- }
- return
- }
-
- if val, _ := ctx.GetSuperSecureCookie(
- base.EncodeMd5(u.Rands+u.Passwd), setting.CookieRememberName); val != u.Name {
- ctx.HTML(200, SIGNIN)
+ ctx.Handle(500, "AutoSignIn", err)
return
}
- isSucceed = true
-
- ctx.Session.Set("uid", u.Id)
- ctx.Session.Set("uname", u.Name)
- if redirectTo, _ := url.QueryUnescape(ctx.GetCookie("redirect_to")); len(redirectTo) > 0 {
- ctx.SetCookie("redirect_to", "", -1, setting.AppSubUrl)
- ctx.Redirect(redirectTo)
+ if isSucceed {
+ if redirectTo, _ := url.QueryUnescape(ctx.GetCookie("redirect_to")); len(redirectTo) > 0 {
+ ctx.SetCookie("redirect_to", "", -1, setting.AppSubUrl)
+ ctx.Redirect(redirectTo)
+ }
+ ctx.Redirect(setting.AppSubUrl + "/")
return
}
- ctx.Redirect(setting.AppSubUrl + "/")
+ ctx.HTML(200, SIGNIN)
}
func SignInPost(ctx *middleware.Context, form auth.SignInForm) {