diff options
author | Unknwon <u@gogs.io> | 2015-08-14 02:43:40 +0800 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2015-08-14 02:43:40 +0800 |
commit | 817b48ed1e083b5291afd339bda573cba14bba8d (patch) | |
tree | 52a38a2c63c49afb45d45ac3fc06b3c730aa9cca /routers/user | |
parent | 1fb53067f478414302096d5d976a3db85df9e2eb (diff) | |
download | gitea-817b48ed1e083b5291afd339bda573cba14bba8d.tar.gz gitea-817b48ed1e083b5291afd339bda573cba14bba8d.zip |
Show owner/poster tags of comments and fix #1312
Diffstat (limited to 'routers/user')
-rw-r--r-- | routers/user/auth.go | 45 |
1 files changed, 9 insertions, 36 deletions
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) { |